changeset 25:8eaf72e2041b

Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl". Fix the problems introduced afterwards.
author Matti Hamalainen <ccr@tnsp.org>
date Sat, 24 Sep 2011 14:16:04 +0300
parents b2dc19044bf3
children be5c117160c4
files src/_edit.h src/acolours.cc src/acolours.h src/aym.cc src/aym.h src/bench.cc src/bench.h src/bitvec.cc src/bitvec.h src/cfgfile.cc src/cfgfile.h src/checks.cc src/checks.h src/colour.h src/colour1.cc src/colour2.cc src/colour3.cc src/colour4.cc src/credits.cc src/dependcy.cc src/dependcy.h src/dialog.cc src/dialog.h src/disppic.cc src/disppic.h src/drawmap.cc src/drawmap.h src/edisplay.cc src/edisplay.h src/editgrid.cc src/editgrid.h src/editlev.cc src/editlev.h src/editloop.cc src/editloop.h src/editobj.cc src/editobj.h src/editsave.cc src/editsave.h src/editzoom.cc src/editzoom.h src/edwidget.h src/endian.cc src/endian.h src/entry.cc src/entry.h src/entry2.cc src/entry2.h src/events.cc src/events.h src/flats.cc src/flats.h src/game.cc src/game.h src/gamedef.h src/gamesky.h src/gcolour1.cc src/gcolour1.h src/gcolour2.cc src/gcolour2.h src/gcolour3.cc src/gcolour3.h src/geom.cc src/gfx.cc src/gfx.h src/gfx3.cc src/gfx3.h src/gotoobj.cc src/gotoobj.h src/help1.cc src/help1.h src/help2.cc src/help2.h src/highlt.cc src/highlt.h src/img.cc src/img.h src/imgscale.cc src/imgscale.h src/imgspect.cc src/imgspect.h src/infobar.cc src/infobar.h src/input.cc src/input.h src/l_align.cc src/l_centre.cc src/l_centre.h src/l_flags.cc src/l_flags.h src/l_misc.cc src/l_prop.cc src/l_super.h src/l_unlink.cc src/l_vertices.cc src/l_vertices.h src/levels.cc src/levels.h src/lists.cc src/lists.h src/locate.cc src/locate.h src/lumpdir.cc src/lumpdir.h src/macro.cc src/macro.h src/masterdir.h src/memory.cc src/menu.cc src/menu.h src/menubar.cc src/menubar.h src/menudata.h src/mkpalette.cc src/mkpalette.h src/modpopup.h src/names.cc src/nop.cc src/objects.cc src/objects.h src/objid.h src/objinfo.cc src/objinfo.h src/oldmenus.cc src/oldmenus.h src/palview.cc src/palview.h src/patchdir.cc src/patchdir.h src/pic2img.cc src/pic2img.h src/prefer.cc src/prefer.h src/r_images.cc src/r_images.h src/r_render.cc src/r_render.h src/record.h src/rgb.h src/rgbbmp.h src/s_centre.cc src/s_centre.h src/s_door.cc src/s_lift.cc src/s_linedefs.cc src/s_linedefs.h src/s_merge.cc src/s_misc.cc src/s_prop.cc src/s_slice.cc src/s_slice.h src/s_split.cc src/s_swapf.cc src/s_swapf.h src/s_vertices.cc src/s_vertices.h src/sanity.cc src/sanity.h src/scrnshot.cc src/selbox.cc src/selbox.h src/selectn.cc src/selectn.h src/selpath.cc src/selpath.h src/selrect.cc src/serialnum.cc src/serialnum.h src/spot.h src/spritdir.cc src/spritdir.h src/sticker.cc src/sticker.h src/t_centre.cc src/t_centre.h src/t_flags.cc src/t_flags.h src/t_prop.cc src/t_spin.cc src/t_spin.h src/textures.cc src/textures.h src/things.cc src/things.h src/trace.cc src/trace.h src/v_centre.cc src/v_centre.h src/v_merge.cc src/v_polyg.cc src/vectext.cc src/vectext.h src/verbmsg.cc src/wadfile.cc src/wadfile.h src/wadlist.cc src/wadlist.h src/wadname.h src/wadnamec.cc src/wadnamec.h src/wadres.cc src/wadres.h src/wads.cc src/wads.h src/wads2.cc src/wads2.h src/warn.cc src/windim.cc src/windim.h src/wstructs.h src/x11.cc src/x11.h src/x_centre.cc src/x_centre.h src/x_exchng.cc src/x_exchng.h src/x_hover.cc src/x_hover.h src/x_mirror.cc src/x_mirror.h src/x_rotate.cc src/x_rotate.h src/xref.cc src/xref.h src/yadex.cc src/yadex.h src/yerror.h src/ymemory.h src/ytime.cc src/ytime.h
diffstat 230 files changed, 26770 insertions(+), 26343 deletions(-) [+]
line wrap: on
line diff
--- a/src/_edit.h	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/_edit.h	Sat Sep 24 14:16:04 2011 +0300
@@ -27,7 +27,7 @@
 */
 
 
-#ifndef YH__EDIT	/* DO NOT INSERT ANYTHING BEFORE THIS LINE */
+#ifndef YH__EDIT		/* DO NOT INSERT ANYTHING BEFORE THIS LINE */
 #define YH__EDIT
 
 
@@ -45,40 +45,40 @@
 // The numbers of the items on the menu bar
 enum
 {
-  MBI_FILE,
-  MBI_EDIT,
-  MBI_VIEW,
-  MBI_SEARCH,
-  MBI_MISC,
-  MBI_OBJECTS,
-  MBI_CHECK,
-  MBI_HELP,
-  MBI_COUNT
+    MBI_FILE,
+    MBI_EDIT,
+    MBI_VIEW,
+    MBI_SEARCH,
+    MBI_MISC,
+    MBI_OBJECTS,
+    MBI_CHECK,
+    MBI_HELP,
+    MBI_COUNT
 };
 
 
 // The numbers of the actual menus (Menu objects)
 enum
 {
-  MBM_FILE,
-  MBM_EDIT,
-  MBM_VIEW,
-  MBM_SEARCH,
-  MBM_MISC_L,  // The "Misc. operations" menus changes with the mode
-  MBM_MISC_S,
-  MBM_MISC_T,
-  MBM_MISC_V,
-  MBM_OBJECTS,
-  MBM_CHECK,
-  MBM_HELP,
-  MBM_COUNT
+    MBM_FILE,
+    MBM_EDIT,
+    MBM_VIEW,
+    MBM_SEARCH,
+    MBM_MISC_L,			// The "Misc. operations" menus changes with the mode
+    MBM_MISC_S,
+    MBM_MISC_T,
+    MBM_MISC_V,
+    MBM_OBJECTS,
+    MBM_CHECK,
+    MBM_HELP,
+    MBM_COUNT
 };
 
 
 typedef enum
 {
-  TOOL_NORMAL,
-  TOOL_SNAP_VERTEX
+    TOOL_NORMAL,
+    TOOL_SNAP_VERTEX
 } tool_t;
 
 
@@ -86,8 +86,7 @@
 // FIXME: make a class of it.
 typedef struct
 {
-  public :
-    int   mb_ino[MBI_COUNT];	// The numbers of the items on the menu bar
+    public:int mb_ino[MBI_COUNT];	// The numbers of the items on the menu bar
     Menu *mb_menu[MBM_COUNT];	// The actual menu objects
 
     int move_speed;		// Movement speed.
@@ -111,21 +110,21 @@
     int pointer_y;
     int pointer_in_window;	// If false, pointer_[xy] are not meaningful.
     Objid clicked;		// The object that was under the pointer when
-				// when the left click occurred. If clicked on
-				// empty space, == CANVAS.
+    // when the left click occurred. If clicked on
+    // empty space, == CANVAS.
     int click_ctrl;		// Was Ctrl pressed at the moment of the click?
     unsigned long click_time;	// Date of last left click in ms
     Objid highlighted;		// The highlighted object
     SelPtr Selected;		// Linked list of selected objects (or NULL)
 
-    selbox_c   *selbox;		// The selection box
+    selbox_c *selbox;		// The selection box
     edisplay_c *edisplay;	// The display manager
-    menubar_c  *menubar;	// The menu bar
-    spot_c     *spot;		// The insertion spot
+    menubar_c *menubar;		// The menu bar
+    spot_c *spot;		// The insertion spot
 
     modpopup_c *modpopup;	// The modal popup menu (only one at a time!)
     char modal;
 } edit_t;
 
 
-#endif  /* DO NOT ADD ANYTHING AFTER THIS LINE */
+#endif /* DO NOT ADD ANYTHING AFTER THIS LINE */
--- a/src/acolours.cc	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/acolours.cc	Sat Sep 24 14:16:04 2011 +0300
@@ -45,13 +45,13 @@
 
 typedef struct
 {
-  rgb_c rgb;
-  char deleted;
+    rgb_c rgb;
+    char deleted;
 } ac_table_entry_t;
 
-static ac_table_entry_t *table     = 0;  // The list
-static acolour_t        table_size = 0;  // The size of the list
-static acolour_t        ac_count   = 0;  // The number of entries really used
+static ac_table_entry_t *table = 0;	// The list
+static acolour_t table_size = 0;	// The size of the list
+static acolour_t ac_count = 0;	// The number of entries really used
 
 
 /*
@@ -59,25 +59,26 @@
  *	Add colour <rgb> to the list of application colours
  *	and return a brand new application colour# for it.
  */
-pcolour_t add_app_colour (rgb_c rgb)
+pcolour_t add_app_colour(rgb_c rgb)
 {
-  size_t i;
+    size_t i;
 
-  for (i = 0; i < table_size; i++)
-    if (table[i].deleted)
-      break;
+    for (i = 0; i < table_size; i++)
+	if (table[i].deleted)
+	    break;
 
-  if (i == table_size)
-  {
-    table_size++;
-    table = (ac_table_entry_t *) realloc (table, table_size * sizeof *table);
-    if (table == NULL)
-      fatal_error (msg_nomem);
-  }
-  ac_count++;
-  table[i].rgb     = rgb;
-  table[i].deleted = 0;
-  return i;
+    if (i == table_size)
+    {
+	table_size++;
+	table =
+	    (ac_table_entry_t *) realloc(table, table_size * sizeof *table);
+	if (table == NULL)
+	    fatal_error(msg_nomem);
+    }
+    ac_count++;
+    table[i].rgb = rgb;
+    table[i].deleted = 0;
+    return i;
 }
 
 
@@ -85,14 +86,15 @@
  *	delete_app_colour
  *	Remove colour# <acn> from the list of application colours.
  */
-void delete_app_colour (acolour_t acn)
+void delete_app_colour(acolour_t acn)
 {
-  if (acn >= table_size)
-    fatal_error ("delete_app_colour called with non-existent colour %d", acn);
-  if (table[acn].deleted)
-    fatal_error ("colour %d deleted twice", acn);
-  ac_count--;
-  table[acn].deleted = 1;
+    if (acn >= table_size)
+	fatal_error("delete_app_colour called with non-existent colour %d",
+		    acn);
+    if (table[acn].deleted)
+	fatal_error("colour %d deleted twice", acn);
+    ac_count--;
+    table[acn].deleted = 1;
 }
 
 
@@ -107,37 +109,37 @@
  *	Return an array containing the physical colour numbers
  *	for the application colours in the list.
  */
-pcolour_t *commit_app_colours ()
+pcolour_t *commit_app_colours()
 {
-  verbmsg ("colours: committing %d colours\n", ac_count);
+    verbmsg("colours: committing %d colours\n", ac_count);
 
-  /* First create an array of RGB values
-     for all the colours in the list. */
-  verbmsg ("colours: rgb_values %p\n");
-  rgb_c *rgb_values = new rgb_c[ac_count];
-  rgb_c *rgb = rgb_values;
-  int items_on_line = 0;
-  for (size_t n = 0; n < table_size; n++)
-    if (! table[n].deleted)
-    {
-      if (items_on_line == 0)
-	verbmsg ("colours: committing: ");
-      verbmsg ("%d ", int (rgb - rgb_values));
-      *rgb++ = table[n].rgb;
-      if (++items_on_line == 16)
-      {
-	verbmsg ("\n");
-	items_on_line = 0;
-      }
-    }
-  if (items_on_line != 0)
-    verbmsg ("\n");
+    /* First create an array of RGB values
+       for all the colours in the list. */
+    verbmsg("colours: rgb_values %p\n");
+    rgb_c *rgb_values = new rgb_c[ac_count];
+    rgb_c *rgb = rgb_values;
+    int items_on_line = 0;
+    for (size_t n = 0; n < table_size; n++)
+	if (!table[n].deleted)
+	{
+	    if (items_on_line == 0)
+		verbmsg("colours: committing: ");
+	    verbmsg("%d ", int (rgb - rgb_values));
+	    *rgb++ = table[n].rgb;
+	    if (++items_on_line == 16)
+	    {
+		verbmsg("\n");
+		items_on_line = 0;
+	    }
+	}
+    if (items_on_line != 0)
+	verbmsg("\n");
 
-  // Then do the actual allocation.
-  committed_colours = ac_count;
-  pcolour_t *app_colours = alloc_colours (rgb_values, committed_colours);
-  delete[] rgb_values;
-  return app_colours;
+    // Then do the actual allocation.
+    committed_colours = ac_count;
+    pcolour_t *app_colours = alloc_colours(rgb_values, committed_colours);
+    delete[]rgb_values;
+    return app_colours;
 }
 
 
@@ -146,10 +148,8 @@
  *	Free all the colours that were allocated by alloc_app_colours().
  *	They are _not_ removed from the list !
  */
-void uncommit_app_colours (pcolour_t *app_colours)
+void uncommit_app_colours(pcolour_t * app_colours)
 {
-  free_colours (app_colours, committed_colours);
-  committed_colours = 0;
+    free_colours(app_colours, committed_colours);
+    committed_colours = 0;
 }
-
-
--- a/src/acolours.h	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/acolours.h	Sat Sep 24 14:16:04 2011 +0300
@@ -17,8 +17,7 @@
 #include "colour.h"
 
 
-pcolour_t add_app_colour (rgb_c rgb);
-void delete_app_colour (acolour_t acn);
-pcolour_t *commit_app_colours ();
-void uncommit_app_colours (pcolour_t *app_colours);
-
+pcolour_t add_app_colour(rgb_c rgb);
+void delete_app_colour(acolour_t acn);
+pcolour_t *commit_app_colours();
+void uncommit_app_colours(pcolour_t * app_colours);
--- a/src/aym.cc	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/aym.cc	Sat Sep 24 14:16:04 2011 +0300
@@ -42,35 +42,28 @@
  *	MAP00 is considered a valid name.
  *	For other names, returns 0.
  */
-int levelname2levelno (const char *name)
+int levelname2levelno(const char *name)
 {
-  const unsigned char *s = (const unsigned char *) name;
-  if (toupper (s[0]) == 'E'
-   && isdigit (s[1])
-   && s[1] != '0'
-   && toupper (s[2]) == 'M'
-   && isdigit (s[3])
-   && s[3] != '0'
-   && s[4] == '\0')
-    return 10 * dectoi (s[1]) + dectoi (s[3]);
-  if (yg_level_name == YGLN_E1M10
-   && toupper (s[0]) == 'E'
-   && isdigit (s[1])
-   && s[1] != '0'
-   && toupper (s[2]) == 'M'
-   && isdigit (s[3])
-   && s[3] != '0'
-   && isdigit (s[4])
-   && s[5] == '\0')
-    return 100 * dectoi (s[1]) + 10 * dectoi (s[3]) + dectoi (s[4]);
-  if (toupper (s[0]) == 'M'
-   && toupper (s[1]) == 'A'
-   && toupper (s[2]) == 'P'
-   && isdigit (s[3])
-   && isdigit (s[4])
-   && s[5] == '\0')
-    return 1000 + 10 * dectoi (s[3]) + dectoi (s[4]);
-  return 0;
+    const unsigned char *s = (const unsigned char *) name;
+    if (toupper(s[0]) == 'E'
+	&& isdigit(s[1])
+	&& s[1] != '0'
+	&& toupper(s[2]) == 'M'
+	&& isdigit(s[3]) && s[3] != '0' && s[4] == '\0')
+	return 10 * dectoi(s[1]) + dectoi(s[3]);
+    if (yg_level_name == YGLN_E1M10
+	&& toupper(s[0]) == 'E'
+	&& isdigit(s[1])
+	&& s[1] != '0'
+	&& toupper(s[2]) == 'M'
+	&& isdigit(s[3]) && s[3] != '0' && isdigit(s[4]) && s[5] == '\0')
+	return 100 * dectoi(s[1]) + 10 * dectoi(s[3]) + dectoi(s[4]);
+    if (toupper(s[0]) == 'M'
+	&& toupper(s[1]) == 'A'
+	&& toupper(s[2]) == 'P'
+	&& isdigit(s[3]) && isdigit(s[4]) && s[5] == '\0')
+	return 1000 + 10 * dectoi(s[3]) + dectoi(s[4]);
+    return 0;
 }
 
 
@@ -85,35 +78,28 @@
  *	- f("MAPxy") > f("ExMy")
  *	- f("MAPxy") > f("ExMyz")
  */
-int levelname2rank (const char *name)
+int levelname2rank(const char *name)
 {
-  const unsigned char *s = (const unsigned char *) name;
-  if (toupper (s[0]) == 'E'
-   && isdigit (s[1])
-   && s[1] != '0'
-   && toupper (s[2]) == 'M'
-   && isdigit (s[3])
-   && s[3] != '0'
-   && s[4] == '\0')
-    return 100 * dectoi (s[1]) + dectoi (s[3]);
-  if (yg_level_name == YGLN_E1M10
-   && toupper (s[0]) == 'E'
-   && isdigit (s[1])
-   && s[1] != '0'
-   && toupper (s[2]) == 'M'
-   && isdigit (s[3])
-   && s[3] != '0'
-   && isdigit (s[4])
-   && s[5] == '\0')
-    return 100 * dectoi (s[1]) + 10 * dectoi (s[3]) + dectoi (s[4]);
-  if (toupper (s[0]) == 'M'
-   && toupper (s[1]) == 'A'
-   && toupper (s[2]) == 'P'
-   && isdigit (s[3])
-   && isdigit (s[4])
-   && s[5] == '\0')
-    return 1000 + 10 * dectoi (s[3]) + dectoi (s[4]);
-  return 0;
+    const unsigned char *s = (const unsigned char *) name;
+    if (toupper(s[0]) == 'E'
+	&& isdigit(s[1])
+	&& s[1] != '0'
+	&& toupper(s[2]) == 'M'
+	&& isdigit(s[3]) && s[3] != '0' && s[4] == '\0')
+	return 100 * dectoi(s[1]) + dectoi(s[3]);
+    if (yg_level_name == YGLN_E1M10
+	&& toupper(s[0]) == 'E'
+	&& isdigit(s[1])
+	&& s[1] != '0'
+	&& toupper(s[2]) == 'M'
+	&& isdigit(s[3]) && s[3] != '0' && isdigit(s[4]) && s[5] == '\0')
+	return 100 * dectoi(s[1]) + 10 * dectoi(s[3]) + dectoi(s[4]);
+    if (toupper(s[0]) == 'M'
+	&& toupper(s[1]) == 'A'
+	&& toupper(s[2]) == 'P'
+	&& isdigit(s[3]) && isdigit(s[4]) && s[5] == '\0')
+	return 1000 + 10 * dectoi(s[3]) + dectoi(s[4]);
+    return 0;
 }
 
 
@@ -121,17 +107,17 @@
  *	spec_path
  *	Extract the path of a spec
  */
-const char *spec_path (const char *spec)
+const char *spec_path(const char *spec)
 {
-  static char path[Y_PATH + 1];
-  size_t n;
+    static char path[Y_PATH + 1];
+    size_t n;
 
-  *path = '\0';
-  strncat (path, spec, sizeof path - 1);
-  for (n = strlen (path); n > 0 && ! al_fisps (path[n-1]); n--)
-    ;
-  path[n] = '\0';
-  return path;
+    *path = '\0';
+    strncat(path, spec, sizeof path - 1);
+    for (n = strlen(path); n > 0 && !al_fisps(path[n - 1]); n--)
+	;
+    path[n] = '\0';
+    return path;
 }
 
 
@@ -142,25 +128,25 @@
  *	For DOS, it's case insensitive and "/" and "\" are equivalent.
  *	FIXME: should canonicalize both names and compare that.
  */
-int fncmp (const char *name1, const char *name2)
+int fncmp(const char *name1, const char *name2)
 {
 #if defined Y_DOS
-  char c1, c2;
-  for (;;)
-  {
-    c1 = tolower ((unsigned char) *name1++);
-    c2 = tolower ((unsigned char) *name2++);
-    if (c1=='\\')
-      c1 = '/';
-    if (c2=='\\')
-      c2 = '/';
-    if (c1 != c2)
-      return c1-c2;
-    if (!c1)
-      return 0;
-  }
+    char c1, c2;
+    for (;;)
+    {
+	c1 = tolower((unsigned char) *name1++);
+	c2 = tolower((unsigned char) *name2++);
+	if (c1 == '\\')
+	    c1 = '/';
+	if (c2 == '\\')
+	    c2 = '/';
+	if (c1 != c2)
+	    return c1 - c2;
+	if (!c1)
+	    return 0;
+    }
 #elif defined Y_UNIX
-  return strcmp (name1, name2);
+    return strcmp(name1, name2);
 #endif
 }
 
@@ -176,14 +162,13 @@
  *	name that's relative to one of the standard
  *	directories is not going to put a "d:" in front of it.
  */
-int is_absolute (const char *filename)
+int is_absolute(const char *filename)
 {
 #if defined Y_UNIX
-return *filename == '/';
+    return *filename == '/';
 #elif defined Y_DOS
-return *filename == '/'
-   || *filename == '\\'
-   || isalpha (*filename) && filename[1] == ':';
+    return *filename == '/'
+	|| *filename == '\\' || isalpha(*filename) && filename[1] == ':';
 #endif
 }
 
@@ -193,22 +178,22 @@
  *	A case-insensitive strcmp()
  *	(same thing as DOS stricmp() or GNU strcasecmp())
  */
-int y_stricmp (const char *s1, const char *s2)
+int y_stricmp(const char *s1, const char *s2)
 {
-for (;;)
-   {
-   if (tolower (*s1) != tolower (*s2))
-      return (unsigned char) *s1 - (unsigned char) *s2;
-   if (! *s1)
-      if (! *s2)
-         return 0;
-      else
-	 return -1;
-   if (! *s2)
-      return 1;
-   s1++;
-   s2++;
-   }
+    for (;;)
+    {
+	if (tolower(*s1) != tolower(*s2))
+	    return (unsigned char) *s1 - (unsigned char) *s2;
+	if (!*s1)
+	    if (!*s2)
+		return 0;
+	    else
+		return -1;
+	if (!*s2)
+	    return 1;
+	s1++;
+	s2++;
+    }
 }
 
 
@@ -217,23 +202,23 @@
  *	A case-insensitive strncmp()
  *	(same thing as DOS strnicmp() or GNU strncasecmp())
  */
-int y_strnicmp (const char *s1, const char *s2, size_t len)
+int y_strnicmp(const char *s1, const char *s2, size_t len)
 {
-while (len-- > 0)
-   {
-   if (tolower (*s1) != tolower (*s2))
-      return (unsigned char) *s1 - (unsigned char) *s2;
-   if (! *s1)
-      if (! *s2)
-         return 0;
-      else
-	 return -1;
-   if (! *s2)
-      return 1;
-   s1++;
-   s2++;
-   }
-return 0;
+    while (len-- > 0)
+    {
+	if (tolower(*s1) != tolower(*s2))
+	    return (unsigned char) *s1 - (unsigned char) *s2;
+	if (!*s1)
+	    if (!*s2)
+		return 0;
+	    else
+		return -1;
+	if (!*s2)
+	    return 1;
+	s1++;
+	s2++;
+    }
+    return 0;
 }
 
 
@@ -241,14 +226,14 @@
  *	y_snprintf
  *	If available, snprintf(). Else sprintf().
  */
-int y_snprintf (char *buf, size_t size, const char *fmt, ...)
+int y_snprintf(char *buf, size_t size, const char *fmt, ...)
 {
-va_list args;
-va_start (args, fmt);
+    va_list args;
+    va_start(args, fmt);
 #ifdef Y_SNPRINTF
-return vsnprintf (buf, size, fmt, args);
+    return vsnprintf(buf, size, fmt, args);
 #else
-return vsprintf (buf, fmt, args);
+    return vsprintf(buf, fmt, args);
 #endif
 }
 
@@ -257,12 +242,12 @@
  *	y_vsnprintf
  *	If available, vsnprintf(). Else vsprintf().
  */
-int y_vsnprintf (char *buf, size_t size, const char *fmt, va_list args)
+int y_vsnprintf(char *buf, size_t size, const char *fmt, va_list args)
 {
 #ifdef Y_SNPRINTF
-return vsnprintf (buf, size, fmt, args);
+    return vsnprintf(buf, size, fmt, args);
 #else
-return vsprintf (buf, fmt, args);
+    return vsprintf(buf, fmt, args);
 #endif
 }
 
@@ -271,13 +256,13 @@
  *	y_strupr
  *	Upper-case a string
  */
-void y_strupr (char *string)
+void y_strupr(char *string)
 {
-  while (*string)
-  {
-    *string = toupper (*string);
-    string++;
-  }
+    while (*string)
+    {
+	*string = toupper(*string);
+	string++;
+    }
 }
 
 /*
@@ -287,19 +272,19 @@
  *	list as const char *). The last string must be followed
  *	by (const char *) 0.
  */
-int is_one_of (const char *needle, ...)
+int is_one_of(const char *needle, ...)
 {
-  va_list args;
-  va_start (args, needle);
-  for (;;)
-  {
-    const char *haystack = va_arg (args, const char *);
-    if (haystack == Y_NULL)
-      break;
-    if (! strcmp (needle, haystack))
-      return 1;
-  }
-  return 0;
+    va_list args;
+    va_start(args, needle);
+    for (;;)
+    {
+	const char *haystack = va_arg(args, const char *);
+	if (haystack == Y_NULL)
+	    break;
+	if (!strcmp(needle, haystack))
+	    return 1;
+    }
+    return 0;
 }
 
 
@@ -309,14 +294,14 @@
  *	Check whether a file exists and is readable.
  *	Returns true if it is, false if it isn't.
  */
-bool file_exists (const char *filename)
+bool file_exists(const char *filename)
 {
-  FILE *test;
+    FILE *test;
 
-  if ((test = fopen (filename, "rb")) == NULL)
-    return 0;
-  fclose (test);
-  return 1;
+    if ((test = fopen(filename, "rb")) == NULL)
+	return 0;
+    fclose(test);
+    return 1;
 }
 
 
@@ -328,51 +313,49 @@
  *	printable characters are replaced by question marks.
  *	Excess characters are replaced by an ellipsis.
  */
-void y_filename (char *buf, size_t size, const char *filename)
+void y_filename(char *buf, size_t size, const char *filename)
 {
-  if (size == 0)
-    return;
-  if (size == 1)
-  {
-    *buf = '\0';
-    return;
-  }
-  size_t len    = strlen (filename);
-  size_t maxlen = size - 1;
+    if (size == 0)
+	return;
+    if (size == 1)
+    {
+	*buf = '\0';
+	return;
+    }
+    size_t len = strlen(filename);
+    size_t maxlen = size - 1;
 
-  if (len > 3 && maxlen <= 3)  // Pathological case, fill with dots
-  {
-    memset (buf, '.', maxlen);
-    buf[maxlen] = '\0';
-    return;
-  }
+    if (len > 3 && maxlen <= 3)	// Pathological case, fill with dots
+    {
+	memset(buf, '.', maxlen);
+	buf[maxlen] = '\0';
+	return;
+    }
 
-  size_t len1 = len;
-  size_t len2 = 0;
-  if (len > maxlen)
-  {
-    len1 = (maxlen - 3) / 2;
-    len2 = maxlen - 3 - len1;
-  }
-  char *p = buf;
-  for (size_t n = 0; n < len1; n++)
-  {
-    *p++ = y_isprint (*filename) ? *filename : '?';
-    filename++;
-  }
-  if (len2 > 0)
-  {
-    *p++ = '.';
-    *p++ = '.';
-    *p++ = '.';
-    filename += len - len1 - len2;
-    for (size_t n = 0; n < len2; n++)
+    size_t len1 = len;
+    size_t len2 = 0;
+    if (len > maxlen)
+    {
+	len1 = (maxlen - 3) / 2;
+	len2 = maxlen - 3 - len1;
+    }
+    char *p = buf;
+    for (size_t n = 0; n < len1; n++)
     {
-      *p++ = y_isprint (*filename) ? *filename : '?';
-      filename++;
+	*p++ = y_isprint(*filename) ? *filename : '?';
+	filename++;
     }
-  }
-  *p++ = '\0';
+    if (len2 > 0)
+    {
+	*p++ = '.';
+	*p++ = '.';
+	*p++ = '.';
+	filename += len - len1 - len2;
+	for (size_t n = 0; n < len2; n++)
+	{
+	    *p++ = y_isprint(*filename) ? *filename : '?';
+	    filename++;
+	}
+    }
+    *p++ = '\0';
 }
- 
-
--- a/src/aym.h	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/aym.h	Sat Sep 24 14:16:04 2011 +0300
@@ -28,32 +28,32 @@
 */
 
 
-#ifndef YH_AYM  /* DO NOT INSERT ANYTHING BEFORE THIS LINE */
+#ifndef YH_AYM			/* DO NOT INSERT ANYTHING BEFORE THIS LINE */
 #define YH_AYM
 
 
-int levelname2levelno (const char *name);
-int levelname2rank (const char *name);
-const char *spec_path (const char *spec);
-int fncmp (const char *name1, const char *name2);
-int is_absolute (const char *filename);
-int y_stricmp (const char *s1, const char *s2);
-int y_strnicmp (const char *s1, const char *s2, size_t len);
-int y_snprintf (char *buf, size_t size, const char *fmt, ...);
-int y_vsnprintf (char *buf, size_t size, const char *fmt, va_list args);
-void y_strupr (char *string);
-int is_one_of (const char *needle, ...);
-bool file_exists (const char *);
-void y_filename (char *buf, size_t size, const char *path);
+int levelname2levelno(const char *name);
+int levelname2rank(const char *name);
+const char *spec_path(const char *spec);
+int fncmp(const char *name1, const char *name2);
+int is_absolute(const char *filename);
+int y_stricmp(const char *s1, const char *s2);
+int y_strnicmp(const char *s1, const char *s2, size_t len);
+int y_snprintf(char *buf, size_t size, const char *fmt, ...);
+int y_vsnprintf(char *buf, size_t size, const char *fmt, va_list args);
+void y_strupr(char *string);
+int is_one_of(const char *needle, ...);
+bool file_exists(const char *);
+void y_filename(char *buf, size_t size, const char *path);
 
 
 /*
  *	within
  *	Is <value> >= <lower_bound> and <= <upper_bound> ?
  */
-inline int within (int value, int lower_bound, int upper_bound)
+inline int within(int value, int lower_bound, int upper_bound)
 {
-  return value >= lower_bound && value <= upper_bound;
+    return value >= lower_bound && value <= upper_bound;
 }
 
 
@@ -61,9 +61,9 @@
  *	outside
  *	Is <value> < <lower_bound> or > <upper_bound> ?
  */
-inline int outside (int value, int lower_bound, int upper_bound)
+inline int outside(int value, int lower_bound, int upper_bound)
 {
-  return value < lower_bound || value > upper_bound;
+    return value < lower_bound || value > upper_bound;
 }
 
 
@@ -72,12 +72,12 @@
  *	If <c> is a decimal digit ("[0-9]"), return its value.
  *	Else, return a negative number.
  */
-inline int dectoi (char c)
+inline int dectoi(char c)
 {
-  if (isdigit ((unsigned char) c))
-    return c - '0';
-  else
-    return -1;
+    if (isdigit((unsigned char) c))
+	return c - '0';
+    else
+	return -1;
 }
 
 
@@ -86,16 +86,16 @@
  *	If <c> is a hexadecimal digit ("[0-9A-Fa-f]"), return its value.
  *	Else, return a negative number.
  */
-inline int hextoi (char c)
+inline int hextoi(char c)
 {
-  if (isdigit ((unsigned char) c))
-    return c - '0';
-  else if (c >= 'a' && c <= 'f')
-    return c - 'a' + 10;
-  else if (c >= 'A' && c <= 'F')
-    return c - 'A' + 10;
-  else
-    return -1;
+    if (isdigit((unsigned char) c))
+	return c - '0';
+    else if (c >= 'a' && c <= 'f')
+	return c - 'a' + 10;
+    else if (c >= 'A' && c <= 'F')
+	return c - 'A' + 10;
+    else
+	return -1;
 }
 
 
@@ -104,16 +104,16 @@
  *	If <c> is a base 36 digit ("[0-9A-Za-z]"), return its value.
  *	Else, return a negative number.
  */
-inline int b36toi (char c)
+inline int b36toi(char c)
 {
-  if (isdigit ((unsigned char) c))
-    return c - '0';
-  else if (islower (c))
-    return c - 'a' + 10;
-  else if (isupper (c))
-    return c - 'A' + 10;
-  else
-    return -1;
+    if (isdigit((unsigned char) c))
+	return c - '0';
+    else if (islower(c))
+	return c - 'a' + 10;
+    else if (isupper(c))
+	return c - 'A' + 10;
+    else
+	return -1;
 }
 
 
@@ -123,33 +123,83 @@
  *	Intentionally not using isalpha() and co. because I
  *	don't want the results to depend on the locale.
  */
-inline bool y_isident (char c)
+inline bool y_isident(char c)
 {
-  switch (c)
-  {
-    case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
-    case 'g': case 'h': case 'i': case 'j': case 'k': case 'l':
-    case 'm': case 'n': case 'o': case 'p': case 'q': case 'r':
-    case 's': case 't': case 'u': case 'v': case 'w': case 'x':
-    case 'y': case 'z':
+    switch (c)
+    {
+    case 'a':
+    case 'b':
+    case 'c':
+    case 'd':
+    case 'e':
+    case 'f':
+    case 'g':
+    case 'h':
+    case 'i':
+    case 'j':
+    case 'k':
+    case 'l':
+    case 'm':
+    case 'n':
+    case 'o':
+    case 'p':
+    case 'q':
+    case 'r':
+    case 's':
+    case 't':
+    case 'u':
+    case 'v':
+    case 'w':
+    case 'x':
+    case 'y':
+    case 'z':
 
-    case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
-    case 'G': case 'H': case 'I': case 'J': case 'K': case 'L':
-    case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R':
-    case 'S': case 'T': case 'U': case 'V': case 'W': case 'X':
-    case 'Y': case 'Z':
+    case 'A':
+    case 'B':
+    case 'C':
+    case 'D':
+    case 'E':
+    case 'F':
+    case 'G':
+    case 'H':
+    case 'I':
+    case 'J':
+    case 'K':
+    case 'L':
+    case 'M':
+    case 'N':
+    case 'O':
+    case 'P':
+    case 'Q':
+    case 'R':
+    case 'S':
+    case 'T':
+    case 'U':
+    case 'V':
+    case 'W':
+    case 'X':
+    case 'Y':
+    case 'Z':
 
-    case '0': case '1': case '2': case '3': case '4': case '5':
-    case '6': case '7': case '8': case '9':
+    case '0':
+    case '1':
+    case '2':
+    case '3':
+    case '4':
+    case '5':
+    case '6':
+    case '7':
+    case '8':
+    case '9':
 
     case '_':
 
-      return true;
+	return true;
 
     default:
 
-      return false;
-  }
+	return false;
+    }
 }
 
 
@@ -159,12 +209,12 @@
  *	other platforms, CR LF.
  *	Return EOF on failure.
  */
-inline int fnewline (FILE *fd)
+inline int fnewline(FILE * fd)
 {
 #ifdef Y_UNIX
-  return putc ('\n', fd);
+    return putc('\n', fd);
 #else
-  return putc ('\r', fd), putc ('\n', fd);
+    return putc('\r', fd), putc('\n', fd);
 #endif
 }
 
@@ -175,9 +225,9 @@
  *
  *	Both the value and the quantum are supposed to be positive.
  */
-inline void round_up (int& value, int quantum)
+inline void round_up(int &value, int quantum)
 {
-  value = ((value + quantum - 1) / quantum) * quantum;
+    value = ((value + quantum - 1) / quantum) * quantum;
 }
 
 
@@ -185,10 +235,10 @@
  *	y_isprint
  *	Is <c> a printable character in ISO-8859-1 ?
  */
-inline bool y_isprint (char c)
+inline bool y_isprint(char c)
 {
-  return (c & 0x60) && (c != 0x7f);
+    return (c & 0x60) && (c != 0x7f);
 }
 
 
-#endif  /* DO NOT ADD ANYTHING AFTER THIS LINE */
+#endif /* DO NOT ADD ANYTHING AFTER THIS LINE */
--- a/src/bench.cc	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/bench.cc	Sat Sep 24 14:16:04 2011 +0300
@@ -40,60 +40,59 @@
 
 
 
-static void bench_LoadPicture ();
+static void bench_LoadPicture();
 
 
 /*
  *	benchmark - run the benchmarks specified by <what>.
  */
-void benchmark (const char *what)
+void benchmark(const char *what)
 {
-  // Insert parsing of <what> here
-  if (! strcmp (what, "loadpic"))
-    bench_LoadPicture ();
+    // Insert parsing of <what> here
+    if (!strcmp(what, "loadpic"))
+	bench_LoadPicture();
 }
 
 
 /*
  *	bench_LoadPicture - run a benchmark of LoadPicture()
  */
-static void bench_LoadPicture ()
+static void bench_LoadPicture()
 {
-  const char *sprite_name = "TROOA1";
-  unsigned long iterations = 100000;
-  const int width = 100;
-  const int height = 100;
-  Lump_loc sprite_loc;
-  
-  wad_res.sprites.loc_by_name (sprite_name, sprite_loc);
-  if (sprite_loc.wad == 0)
-    fprintf (stderr, "Could not locate sprite %s\n", sprite_name);
+    const char *sprite_name = "TROOA1";
+    unsigned long iterations = 100000;
+    const int width = 100;
+    const int height = 100;
+    Lump_loc sprite_loc;
 
-  Img img (width, height, false);
-  struct tms t0;
-  times (&t0);
-  for (unsigned long n = 0; n < iterations; n++)
-    LoadPicture (img, sprite_name, sprite_loc, 0, 0, 0, 0);
-  struct tms t1;
-  times (&t1);
+    wad_res.sprites.loc_by_name(sprite_name, sprite_loc);
+    if (sprite_loc.wad == 0)
+	fprintf(stderr, "Could not locate sprite %s\n", sprite_name);
+
+    Img img(width, height, false);
+    struct tms t0;
+    times(&t0);
+    for (unsigned long n = 0; n < iterations; n++)
+	LoadPicture(img, sprite_name, sprite_loc, 0, 0, 0, 0);
+    struct tms t1;
+    times(&t1);
 
 // Glibc 2.1 (?) has a broken CLOCKS_PER_SEC.
 #ifndef CLOCKS_PER_SEC
 #define CLOCKS_PER_SEC CLK_TCK
 #endif
-  const char *unit  = "s";
-  double value = (double) (t1.tms_utime - t0.tms_utime)
-		 / CLOCKS_PER_SEC / iterations;
-  if (value < 1E-3)
-  {
-    unit = "µs";
-    value *= 1000000;
-  }
-  else if (value < 1.0)
-  {
-    unit = "ms";
-    value *= 1000;
-  }
-  printf ("LoadPicture: %f %s per call\n", value, unit);
+    const char *unit = "s";
+    double value = (double) (t1.tms_utime - t0.tms_utime)
+	/ CLOCKS_PER_SEC / iterations;
+    if (value < 1E-3)
+    {
+	unit = "µs";
+	value *= 1000000;
+    }
+    else if (value < 1.0)
+    {
+	unit = "ms";
+	value *= 1000;
+    }
+    printf("LoadPicture: %f %s per call\n", value, unit);
 }
-
--- a/src/bench.h	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/bench.h	Sat Sep 24 14:16:04 2011 +0300
@@ -5,11 +5,11 @@
  */
 
 
-#ifndef YH_BENCH  /* DO NOT INSERT ANYTHING BEFORE THIS LINE */
+#ifndef YH_BENCH		/* DO NOT INSERT ANYTHING BEFORE THIS LINE */
 #define YH_BENCH
 
 
-void benchmark (const char *what);
+void benchmark(const char *what);
 
 
-#endif  /* DO NOT ADD ANYTHING AFTER THIS LINE */
+#endif /* DO NOT ADD ANYTHING AFTER THIS LINE */
--- a/src/bitvec.cc	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/bitvec.cc	Sat Sep 24 14:16:04 2011 +0300
@@ -9,5 +9,3 @@
 
 
 const char _bitvec_msg1[] = "bitvec::frob: invalid op = %d";
-
-
--- a/src/bitvec.h	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/bitvec.h	Sat Sep 24 14:16:04 2011 +0300
@@ -28,7 +28,7 @@
 */
 
 
-#ifndef YH_BITVEC  /* DO NOT INSERT ANYTHING BEFORE THIS LINE */
+#ifndef YH_BITVEC		/* DO NOT INSERT ANYTHING BEFORE THIS LINE */
 #define YH_BITVEC
 
 
@@ -39,72 +39,71 @@
 
 
 typedef enum
-   {
-   BV_SET    = 's',
-   BV_CLEAR  = 'c',
-   BV_TOGGLE = 't'
-   } bitvec_op_t;
+{
+    BV_SET = 's',
+    BV_CLEAR = 'c',
+    BV_TOGGLE = 't'
+} bitvec_op_t;
 
 
 extern const char _bitvec_msg1[];
 
 
 class bitvec_c
-   {
-   public :
-      bitvec_c (size_t n_elements)
-         { 
-	 a = (char *) GetMemory (n_elements / CHAR_BIT + 1);
- 	 memset (a, 0, n_elements / CHAR_BIT + 1);
-         _n_elements = n_elements;
-         }
+{
+    public: bitvec_c(size_t n_elements)
+    {
+	a = (char *) GetMemory(n_elements / CHAR_BIT + 1);
+	memset(a, 0, n_elements / CHAR_BIT + 1);
+	_n_elements = n_elements;
+    }
 
-      ~bitvec_c ()
-         {
-         FreeMemory (a);
-         }
+     ~bitvec_c()
+    {
+	FreeMemory(a);
+    }
 
-      size_t nelements () const  // Return the number of elements
-         {
-         return _n_elements;
-         }
+    size_t nelements() const	// Return the number of elements
+    {
+	return _n_elements;
+    }
 
-      int get (size_t n) const  // Get bit <n>
-         {
-         return a[n/CHAR_BIT] & (1 << (n % CHAR_BIT));
-         }
+    int get(size_t n) const	// Get bit <n>
+    {
+	return a[n / CHAR_BIT] & (1 << (n % CHAR_BIT));
+    }
 
-      void set (size_t n)  // Set bit <n> to 1
-         {
-         a[n/CHAR_BIT] |= 1 << (n % CHAR_BIT);
-         }
+    void set(size_t n)		// Set bit <n> to 1
+    {
+	a[n / CHAR_BIT] |= 1 << (n % CHAR_BIT);
+    }
 
-      void unset (size_t n)  // Set bit <n> to 0
-         {
-         a[n/CHAR_BIT] &= ~(1 << (n % CHAR_BIT));
-         }
+    void unset(size_t n)	// Set bit <n> to 0
+    {
+	a[n / CHAR_BIT] &= ~(1 << (n % CHAR_BIT));
+    }
 
-      void toggle (size_t n)  // Toggle bit <n>
- 	 {
-	 a[n/CHAR_BIT] ^= (1 << (n % CHAR_BIT));
-	 }
+    void toggle(size_t n)	// Toggle bit <n>
+    {
+	a[n / CHAR_BIT] ^= (1 << (n % CHAR_BIT));
+    }
 
-      void frob (size_t n, bitvec_op_t op)  // Set, unset or toggle bit <n>
-         {
-	 if (op == BV_SET)
-	    set (n);
-	 else if (op == BV_CLEAR)
-	    unset (n);
-	 else if (op == BV_TOGGLE)
-	    toggle (n);
-	 else
-	    nf_bug (_bitvec_msg1, (int) op);
-         }
+    void frob(size_t n, bitvec_op_t op)	// Set, unset or toggle bit <n>
+    {
+	if (op == BV_SET)
+	    set(n);
+	else if (op == BV_CLEAR)
+	    unset(n);
+	else if (op == BV_TOGGLE)
+	    toggle(n);
+	else
+	    nf_bug(_bitvec_msg1, (int) op);
+    }
 
-   private :
-      size_t _n_elements;
-      char *a;
-   };
+  private:
+    size_t _n_elements;
+    char *a;
+};
 
 
-#endif  /* DO NOT ADD ANYTHING AFTER THIS LINE */
+#endif /* DO NOT ADD ANYTHING AFTER THIS LINE */
--- a/src/cfgfile.cc	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/cfgfile.cc	Sat Sep 24 14:16:04 2011 +0300
@@ -48,511 +48,511 @@
  */
 typedef enum
 {
-  // Boolean (toggle)
-  // Receptacle is of type bool
-  // data_ptr is of type (bool *)
-  OPT_BOOLEAN,
+    // Boolean (toggle)
+    // Receptacle is of type bool
+    // data_ptr is of type (bool *)
+    OPT_BOOLEAN,
 
-  // "yes", "no", "ask"
-  // Receptacle is of type confirm_t
-  // data_ptr is of type confirm_t
-  OPT_CONFIRM,
+    // "yes", "no", "ask"
+    // Receptacle is of type confirm_t
+    // data_ptr is of type confirm_t
+    OPT_CONFIRM,
 
-  // Integer number,
-  // Receptacle is of type int
-  // data_ptr is of type (int *)
-  OPT_INTEGER,
+    // Integer number,
+    // Receptacle is of type int
+    // data_ptr is of type (int *)
+    OPT_INTEGER,
 
-  // Unsigned long integer
-  // Receptacle is of type unsigned
-  // data_ptr is of type (unsigned long *)
-  OPT_UNSIGNED,
+    // Unsigned long integer
+    // Receptacle is of type unsigned
+    // data_ptr is of type (unsigned long *)
+    OPT_UNSIGNED,
 
-  // Window dimension, either integer (pixels) or integer%
-  // (percentage of total display dimension)
-  // Receptacle is of type ...
-  // data_ptr is of type ...
-  OPT_WINDIM,
+    // Window dimension, either integer (pixels) or integer%
+    // (percentage of total display dimension)
+    // Receptacle is of type ...
+    // data_ptr is of type ...
+    OPT_WINDIM,
 
-  // String
-  // Receptacle is of type (char[9])
-  // data_ptr is of type (char *)
-  OPT_STRINGBUF8,
+    // String
+    // Receptacle is of type (char[9])
+    // data_ptr is of type (char *)
+    OPT_STRINGBUF8,
 
-  // String
-  // Receptacle is of type (const char *)
-  // data_ptr is of type (const char **)
-  OPT_STRINGPTR,
+    // String
+    // Receptacle is of type (const char *)
+    // data_ptr is of type (const char **)
+    OPT_STRINGPTR,
 
-  // String, but store in a list
-  // Receptacle is of type ??
-  // data_ptr is of type ??
-  OPT_STRINGPTRACC,
+    // String, but store in a list
+    // Receptacle is of type ??
+    // data_ptr is of type ??
+    OPT_STRINGPTRACC,
 
-  // List of strings
-  // Receptacle is of type (const char *[])
-  // data_ptr is of type (const char ***)
-  OPT_STRINGPTRLIST,
+    // List of strings
+    // Receptacle is of type (const char *[])
+    // data_ptr is of type (const char ***)
+    OPT_STRINGPTRLIST,
 
-  // End of the options description
-  OPT_END
+    // End of the options description
+    OPT_END
 } opt_type_t;
 
 typedef struct
 {
-  const char *long_name;	// Command line arg. or keyword
-  const char *short_name;	// Abbreviated command line argument
-  opt_type_t opt_type;		// Type of this option
-  const char *flags;		// Flags for this option :
-				// "1" = process only on pass 1 of
-				//       parse_command_line_options()
-				// "b" = BGI only (ignored ifndef Y_BGI)
-				// "x" = X only (ignored ifndef Y_X11)
-  const char *desc;		// Description of the option
-  void *data_ptr;		// Pointer to the data
+    const char *long_name;	// Command line arg. or keyword
+    const char *short_name;	// Abbreviated command line argument
+    opt_type_t opt_type;	// Type of this option
+    const char *flags;		// Flags for this option :
+    // "1" = process only on pass 1 of
+    //       parse_command_line_options()
+    // "b" = BGI only (ignored ifndef Y_BGI)
+    // "x" = X only (ignored ifndef Y_X11)
+    const char *desc;		// Description of the option
+    void *data_ptr;		// Pointer to the data
 } opt_desc_t;
 
 /* The first option has neither long name nor short name.
    It is used for "lonely" arguments (i.e. file names). */
 opt_desc_t options[] =		// Description of the command line options
 {
-  { 0,
-    0,
-    OPT_STRINGPTRACC,
-    0,
-    "Patch wad file",
-    &PatchWads },
+    {0,
+     0,
+     OPT_STRINGPTRACC,
+     0,
+     "Patch wad file",
+     &PatchWads},
 
-  { "autoscroll",
-    0,
-    OPT_BOOLEAN,
-    0,
-    "Enable autoscrolling",
-    &autoscroll },
+    {"autoscroll",
+     0,
+     OPT_BOOLEAN,
+     0,
+     "Enable autoscrolling",
+     &autoscroll},
 
-  { "autoscroll_amp",
-    0,
-    OPT_UNSIGNED,
-    0,
-    "Amp. of scrolling (% of screen size)",
-    &autoscroll_amp },
+    {"autoscroll_amp",
+     0,
+     OPT_UNSIGNED,
+     0,
+     "Amp. of scrolling (% of screen size)",
+     &autoscroll_amp},
 
-  { "autoscroll_edge",
-    0,
-    OPT_UNSIGNED,
-    0,
-    "Max. dist. to edge (pixels)",
-    &autoscroll_edge },
+    {"autoscroll_edge",
+     0,
+     OPT_UNSIGNED,
+     0,
+     "Max. dist. to edge (pixels)",
+     &autoscroll_edge},
 
-  { 0,
-    "b",
-    OPT_STRINGPTR,
-    0,
-    "Run benchmark and exit successfully",
-    &bench },
+    {0,
+     "b",
+     OPT_STRINGPTR,
+     0,
+     "Run benchmark and exit successfully",
+     &bench},
 
-  { "blindly_swap_sidedefs",
-    0,
-    OPT_BOOLEAN,
-    0,
-    "Blindly swap sidedefs on a linedef",
-    &blindly_swap_sidedefs },
+    {"blindly_swap_sidedefs",
+     0,
+     OPT_BOOLEAN,
+     0,
+     "Blindly swap sidedefs on a linedef",
+     &blindly_swap_sidedefs},
 
-  { "config_file",
-    "f",
-    OPT_STRINGPTR,
-    "1",
-    "Config file",
-    &config_file },
+    {"config_file",
+     "f",
+     OPT_STRINGPTR,
+     "1",
+     "Config file",
+     &config_file},
 
-  { "copy_linedef_reuse_sidedefs",
-    0,
-    OPT_BOOLEAN,
-    0,
-    "Use same sidedefs as original linedef",
-    &copy_linedef_reuse_sidedefs },
+    {"copy_linedef_reuse_sidedefs",
+     0,
+     OPT_BOOLEAN,
+     0,
+     "Use same sidedefs as original linedef",
+     &copy_linedef_reuse_sidedefs},
 
-  { "debug",
-    "d",
-    OPT_BOOLEAN,
-    0,
-    "Debug mode",
-    &Debug },
+    {"debug",
+     "d",
+     OPT_BOOLEAN,
+     0,
+     "Debug mode",
+     &Debug},
 
-  { "default_ceiling_height",
-    0,
-    OPT_INTEGER,
-    0,
-    "Default ceiling height",
-    &default_ceiling_height },
+    {"default_ceiling_height",
+     0,
+     OPT_INTEGER,
+     0,
+     "Default ceiling height",
+     &default_ceiling_height},
 
-  { "default_ceiling_texture",
-    0,
-    OPT_STRINGBUF8,
-    0,
-    "Default ceiling texture",
-    default_ceiling_texture },
+    {"default_ceiling_texture",
+     0,
+     OPT_STRINGBUF8,
+     0,
+     "Default ceiling texture",
+     default_ceiling_texture},
 
-  { "default_floor_height",
-    0,
-    OPT_INTEGER,
-    0,
-    "Default floor height",
-    &default_floor_height },
+    {"default_floor_height",
+     0,
+     OPT_INTEGER,
+     0,
+     "Default floor height",
+     &default_floor_height},
 
-  { "default_floor_texture",
-    0,
-    OPT_STRINGBUF8,
-    0,
-    "Default floor texture",
-    default_floor_texture },
+    {"default_floor_texture",
+     0,
+     OPT_STRINGBUF8,
+     0,
+     "Default floor texture",
+     default_floor_texture},
 
-  { "default_light_level",
-    0,
-    OPT_INTEGER,
-    0,
-    "Default light level",
-    &default_light_level },
+    {"default_light_level",
+     0,
+     OPT_INTEGER,
+     0,
+     "Default light level",
+     &default_light_level},
 
-  { "default_lower_texture",
-    0,
-    OPT_STRINGBUF8,
-    0,
-    "Default lower texture",
-    default_lower_texture },
+    {"default_lower_texture",
+     0,
+     OPT_STRINGBUF8,
+     0,
+     "Default lower texture",
+     default_lower_texture},
 
-  { "default_middle_texture",
-    0,
-    OPT_STRINGBUF8,
-    0,
-    "Default middle texture",
-    default_middle_texture },
+    {"default_middle_texture",
+     0,
+     OPT_STRINGBUF8,
+     0,
+     "Default middle texture",
+     default_middle_texture},
 
-  { "default_thing",
-    0,
-    OPT_INTEGER,
-    0,
-    "Default thing number",
-    &default_thing },
+    {"default_thing",
+     0,
+     OPT_INTEGER,
+     0,
+     "Default thing number",
+     &default_thing},
 
-  { "default_upper_texture",
-    0,
-    OPT_STRINGBUF8,
-    0,
-    "Default upper texture",
-    default_upper_texture },
+    {"default_upper_texture",
+     0,
+     OPT_STRINGBUF8,
+     0,
+     "Default upper texture",
+     default_upper_texture},
 
-  { "digit_zoom_base",
-    0,
-    OPT_INTEGER,
-    0,
-    "[0]-[9]: base zoom factor (in %)",
-    &digit_zoom_base },
+    {"digit_zoom_base",
+     0,
+     OPT_INTEGER,
+     0,
+     "[0]-[9]: base zoom factor (in %)",
+     &digit_zoom_base},
 
-  { "digit_zoom_step",
-    0,
-    OPT_INTEGER,
-    0,
-    "[0]-[9]: step between factors (in %)",
-    &digit_zoom_step },
+    {"digit_zoom_step",
+     0,
+     OPT_INTEGER,
+     0,
+     "[0]-[9]: step between factors (in %)",
+     &digit_zoom_step},
 
-  { "double_click_timeout",
-    0,
-    OPT_INTEGER,
-    0,
-    "Max delay in ms between clicks",
-    &double_click_timeout },
+    {"double_click_timeout",
+     0,
+     OPT_INTEGER,
+     0,
+     "Max delay in ms between clicks",
+     &double_click_timeout},
 
-  { "expert",
-    0,
-    OPT_BOOLEAN,
-    0,
-    "Expert mode",
-    &Expert },
+    {"expert",
+     0,
+     OPT_BOOLEAN,
+     0,
+     "Expert mode",
+     &Expert},
 
-  { "file",
-    0,
-    OPT_STRINGPTRLIST,
-    0,
-    "Patch wad file",
-    &PatchWads },
+    {"file",
+     0,
+     OPT_STRINGPTRLIST,
+     0,
+     "Patch wad file",
+     &PatchWads},
 
-  { "font",
-    "fn",
-    OPT_STRINGPTR,
-    0,
-    "(X11 only) Font name",
-    &font_name },
+    {"font",
+     "fn",
+     OPT_STRINGPTR,
+     0,
+     "(X11 only) Font name",
+     &font_name},
 
-  { "game",
-    "g",
-    OPT_STRINGPTR,
-    0,
-    "Game",
-    &Game },
+    {"game",
+     "g",
+     OPT_STRINGPTR,
+     0,
+     "Game",
+     &Game},
 
-  { "grid_max",
-    0,
-    OPT_INTEGER,
-    0,
-    "Max grid step (map units)",
-    &GridMax },
+    {"grid_max",
+     0,
+     OPT_INTEGER,
+     0,
+     "Max grid step (map units)",
+     &GridMax},
 
-  { "grid_min",
-    0,
-    OPT_INTEGER,
-    0,
-    "Min grid step (map units)",
-    &GridMin },
+    {"grid_min",
+     0,
+     OPT_INTEGER,
+     0,
+     "Min grid step (map units)",
+     &GridMin},
 
-  { "grid_pixels_min",
-    0,
-    OPT_INTEGER,
-    0,
-    "Min grid step (pixels)",
-    &grid_pixels_min },
+    {"grid_pixels_min",
+     0,
+     OPT_INTEGER,
+     0,
+     "Min grid step (pixels)",
+     &grid_pixels_min},
 
-  { "height",
-    "h",
-    OPT_WINDIM,
-    "x",
-    "(X11 only) Initial window height",
-    &initial_window_height },
+    {"height",
+     "h",
+     OPT_WINDIM,
+     "x",
+     "(X11 only) Initial window height",
+     &initial_window_height},
 
-  { "help",
-    "?",
-    OPT_BOOLEAN,
-    "1",
-    "Show usage summary",
-    &show_help },
+    {"help",
+     "?",
+     OPT_BOOLEAN,
+     "1",
+     "Show usage summary",
+     &show_help},
 
-  { "idle_sleep_ms",
-    0,
-    OPT_INTEGER,
-    0,
-    "ms to sleep before XPending()",
-    &idle_sleep_ms },
+    {"idle_sleep_ms",
+     0,
+     OPT_INTEGER,
+     0,
+     "ms to sleep before XPending()",
+     &idle_sleep_ms},
 
-  { "info_bar",
-    0,
-    OPT_BOOLEAN,
-    0,
-    "Show the info bar",
-    &InfoShown },
+    {"info_bar",
+     0,
+     OPT_BOOLEAN,
+     0,
+     "Show the info bar",
+     &InfoShown},
 
-  { "insert_vertex_split_linedef",
-    0,
-    OPT_CONFIRM,
-    0,
-    "Split ld after ins. vertex",
-    &insert_vertex_split_linedef },
+    {"insert_vertex_split_linedef",
+     0,
+     OPT_CONFIRM,
+     0,
+     "Split ld after ins. vertex",
+     &insert_vertex_split_linedef},
 
-  { "insert_vertex_merge_vertices",
-    0,
-    OPT_CONFIRM,
-    0,
-    "Merge vertices after ins. vertex",
-    &insert_vertex_merge_vertices },
+    {"insert_vertex_merge_vertices",
+     0,
+     OPT_CONFIRM,
+     0,
+     "Merge vertices after ins. vertex",
+     &insert_vertex_merge_vertices},
 
-  { "iwad1",
-    "i1",
-    OPT_STRINGPTR,
-    0,
-    "The name of the Doom/Ultimate D. iwad",
-    &Iwad1 },
+    {"iwad1",
+     "i1",
+     OPT_STRINGPTR,
+     0,
+     "The name of the Doom/Ultimate D. iwad",
+     &Iwad1},
 
-  { "iwad2",
-    "i2",
-    OPT_STRINGPTR,
-    0,
-    "The name of the Doom II/Final D. iwad",
-    &Iwad2 },
+    {"iwad2",
+     "i2",
+     OPT_STRINGPTR,
+     0,
+     "The name of the Doom II/Final D. iwad",
+     &Iwad2},
 
-  { "iwad3",
-    "i3",
-    OPT_STRINGPTR,
-    0,
-    "The name of the Heretic iwad",
-    &Iwad3 },
+    {"iwad3",
+     "i3",
+     OPT_STRINGPTR,
+     0,
+     "The name of the Heretic iwad",
+     &Iwad3},
 
-  { "iwad4",
-    "i4",
-    OPT_STRINGPTR,
-    0,
-    "The name of the Hexen iwad",
-    &Iwad4 },
+    {"iwad4",
+     "i4",
+     OPT_STRINGPTR,
+     0,
+     "The name of the Hexen iwad",
+     &Iwad4},
 
-  { "iwad5",
-    "i5",
-    OPT_STRINGPTR,
-    0,
-    "The name of the Strife iwad",
-    &Iwad5 },
+    {"iwad5",
+     "i5",
+     OPT_STRINGPTR,
+     0,
+     "The name of the Strife iwad",
+     &Iwad5},
 
-  { "iwad6",
-    "i6",
-    OPT_STRINGPTR,
-    0,
-    "The name of the Doom alpha 0.2 iwad",
-    &Iwad6 },
+    {"iwad6",
+     "i6",
+     OPT_STRINGPTR,
+     0,
+     "The name of the Doom alpha 0.2 iwad",
+     &Iwad6},
 
-  { "iwad7",
-    "i7",
-    OPT_STRINGPTR,
-    0,
-    "The name of the Doom alpha 0.4 iwad",
-    &Iwad7 },
+    {"iwad7",
+     "i7",
+     OPT_STRINGPTR,
+     0,
+     "The name of the Doom alpha 0.4 iwad",
+     &Iwad7},
 
-  { "iwad8",
-    "i8",
-    OPT_STRINGPTR,
-    0,
-    "The name of the Doom alpha 0.5 iwad",
-    &Iwad8 },
+    {"iwad8",
+     "i8",
+     OPT_STRINGPTR,
+     0,
+     "The name of the Doom alpha 0.5 iwad",
+     &Iwad8},
 
-  { "iwad9",
-    "i9",
-    OPT_STRINGPTR,
-    0,
-    "The name of the Doom press rel. iwad",
-    &Iwad9 },
+    {"iwad9",
+     "i9",
+     OPT_STRINGPTR,
+     0,
+     "The name of the Doom press rel. iwad",
+     &Iwad9},
 
-  { "iwad10",
-    "i10",
-    OPT_STRINGPTR,
-    0,
-    "The name of the Strife 1.0 iwad",
-    &Iwad10 },
+    {"iwad10",
+     "i10",
+     OPT_STRINGPTR,
+     0,
+     "The name of the Strife 1.0 iwad",
+     &Iwad10},
 
-  { "no_pixmap",
-    "P",
-    OPT_BOOLEAN,
-    0,
-    "(X11 only) Use no pixmap",
-    &no_pixmap },
+    {"no_pixmap",
+     "P",
+     OPT_BOOLEAN,
+     0,
+     "(X11 only) Use no pixmap",
+     &no_pixmap},
 
-  { "pwad",
-    "pw",
-    OPT_STRINGPTRACC,
-    0,
-    "Pwad file to load",
-    &PatchWads },
+    {"pwad",
+     "pw",
+     OPT_STRINGPTRACC,
+     0,
+     "Pwad file to load",
+     &PatchWads},
 
-  { "quiet",
-    "q",
-    OPT_BOOLEAN,
-    0,
-    "Quiet mode",
-    &Quiet },
+    {"quiet",
+     "q",
+     OPT_BOOLEAN,
+     0,
+     "Quiet mode",
+     &Quiet},
 
-  { "quieter",
-    "qq",
-    OPT_BOOLEAN,
-    0,
-    "Quieter mode",
-    &Quieter },
+    {"quieter",
+     "qq",
+     OPT_BOOLEAN,
+     0,
+     "Quieter mode",
+     &Quieter},
 
-  { "scroll_less",
-    0,
-    OPT_UNSIGNED,
-    0,
-    "Amp. of scrolling (% of screen size)",
-    &scroll_less },
+    {"scroll_less",
+     0,
+     OPT_UNSIGNED,
+     0,
+     "Amp. of scrolling (% of screen size)",
+     &scroll_less},
 
-  { "scroll_more",
-    0,
-    OPT_UNSIGNED,
-    0,
-    "Amp. of scrolling (% of screen size)",
-    &scroll_more },
+    {"scroll_more",
+     0,
+     OPT_UNSIGNED,
+     0,
+     "Amp. of scrolling (% of screen size)",
+     &scroll_more},
 
-  { "select0",
-    "s0",
-    OPT_BOOLEAN,
-    0,
-    "Automatic selection of 0th object",
-    &Select0 },
+    {"select0",
+     "s0",
+     OPT_BOOLEAN,
+     0,
+     "Automatic selection of 0th object",
+     &Select0},
 
-  { "sprite_scale",
-    0,
-    OPT_INTEGER,
-    0,
-    "Relative scale of sprites",
-    &sprite_scale },
+    {"sprite_scale",
+     0,
+     OPT_INTEGER,
+     0,
+     "Relative scale of sprites",
+     &sprite_scale},
 
-  { "swap_buttons",
-    "sb",
-    OPT_BOOLEAN,
-    0,
-    "Swap mouse buttons",
-    &SwapButtons },
+    {"swap_buttons",
+     "sb",
+     OPT_BOOLEAN,
+     0,
+     "Swap mouse buttons",
+     &SwapButtons},
 
-  { "text_dot",
-    "td",
-    OPT_BOOLEAN,
-    0,
-    "DrawScreenText debug flag",
-    &text_dot },
+    {"text_dot",
+     "td",
+     OPT_BOOLEAN,
+     0,
+     "DrawScreenText debug flag",
+     &text_dot},
 
-  { "verbose",
-    "v",
-    OPT_BOOLEAN,
-    "1",
-    "Verbose mode",
-    &verbose },
+    {"verbose",
+     "v",
+     OPT_BOOLEAN,
+     "1",
+     "Verbose mode",
+     &verbose},
 
-  { "welcome_message",
-    0, 
-    OPT_BOOLEAN,
-    0,
-    "Print welcome message",
-    &welcome_message },
+    {"welcome_message",
+     0,
+     OPT_BOOLEAN,
+     0,
+     "Print welcome message",
+     &welcome_message},
 
-  { "width",
-    "w",
-    OPT_WINDIM,
-    "x",
-    "(X11 only) Initial window width",
-    &initial_window_width },
+    {"width",
+     "w",
+     OPT_WINDIM,
+     "x",
+     "(X11 only) Initial window width",
+     &initial_window_width},
 
-  { "zoom_default",
-    "z",
-    OPT_INTEGER,
-    0,
-    "Initial zoom factor",
-    &zoom_default },
+    {"zoom_default",
+     "z",
+     OPT_INTEGER,
+     0,
+     "Initial zoom factor",
+     &zoom_default},
 
-  { "zoom_step",
-    0,
-    OPT_INTEGER,
-    0,
-    "Step between zoom factors (in %)",
-    &zoom_step },
+    {"zoom_step",
+     0,
+     OPT_INTEGER,
+     0,
+     "Step between zoom factors (in %)",
+     &zoom_step},
 
-  { 0,
-    0,
-    OPT_END,
-    0,
-    0,
-    0 }
+    {0,
+     0,
+     OPT_END,
+     0,
+     0,
+     0}
 };
 
 
 typedef enum
 {
-  CFG_PARSE_            = 0x00,
-  CFG_PARSE_MAGIC_ERROR = 0x01,
-  CFG_PARSE_MAGIC_WARN  = 0x02,
-  CFG_PARSE_ANAL_NAME   = 0x04,
-  CFG_PARSE_ANAL_SYNTAX = 0x08
+    CFG_PARSE_ = 0x00,
+    CFG_PARSE_MAGIC_ERROR = 0x01,
+    CFG_PARSE_MAGIC_WARN = 0x02,
+    CFG_PARSE_ANAL_NAME = 0x04,
+    CFG_PARSE_ANAL_SYNTAX = 0x08
 } cfg_parse_flags_t;
 
 
-static void append_item_to_list (const char ***list, const char *item);
-static int parse_config_file (const char *filename,
-  cfg_parse_flags_t flags = CFG_PARSE_);
-static confirm_t confirm_e2i (const char *external);
-static const char *confirm_i2e (confirm_t internal);
+static void append_item_to_list(const char ***list, const char *item);
+static int parse_config_file(const char *filename,
+			     cfg_parse_flags_t flags = CFG_PARSE_);
+static confirm_t confirm_e2i(const char *external);
+static const char *confirm_i2e(confirm_t internal);
 
 
 /*
@@ -562,24 +562,24 @@
  *	one call to parse_config_file() returned non-zero), zero
  *	otherwise.
  */
-int parse_config_file_default ()
+int parse_config_file_default()
 {
-  int rc = 0;
-  int matches;
-  const char *pathname;
-  const char *name = "yadex.cfg";
-  Locate locate (yadex_etc_path, name, true);
+    int rc = 0;
+    int matches;
+    const char *pathname;
+    const char *name = "yadex.cfg";
+    Locate locate(yadex_etc_path, name, true);
 
-  for (matches = 0; (pathname = locate.get_next ()) != NULL; matches++)
-  {
-    printf ("Reading config file \"%s\".\n", pathname);
-    int r = parse_config_file (pathname);
-    if (r != 0)
-      rc = 1;
-  }
-  if (matches == 0)
-    warn ("%s: not found\n", name);
-  return rc;
+    for (matches = 0; (pathname = locate.get_next()) != NULL; matches++)
+    {
+	printf("Reading config file \"%s\".\n", pathname);
+	int r = parse_config_file(pathname);
+	if (r != 0)
+	    rc = 1;
+    }
+    if (matches == 0)
+	warn("%s: not found\n", name);
+    return rc;
 }
 
 
@@ -590,19 +590,19 @@
  *	parse error occurred (i.e. parse_config_file() returned
  *	non-zero), zero otherwise.
  */
-int parse_config_file_user (const char *name)
+int parse_config_file_user(const char *name)
 {
-  const char *pathname;
-  Locate locate (yadex_etc_path, name, false);
-  
-  pathname = locate.get_next ();
-  if (pathname == NULL)
-  {
-    err ("%s: not found", name);
-    return 1;
-  }
-  printf ("Reading config file \"%s\".\n", pathname);
-  return parse_config_file (pathname);
+    const char *pathname;
+    Locate locate(yadex_etc_path, name, false);
+
+    pathname = locate.get_next();
+    if (pathname == NULL)
+    {
+	err("%s: not found", name);
+	return 1;
+    }
+    printf("Reading config file \"%s\".\n", pathname);
+    return parse_config_file(pathname);
 }
 
 
@@ -633,302 +633,301 @@
  *	Return 0 on success, <>0 on failure.
  */
 #define RETURN_FAILURE do { rc = 1; goto byebye; } while (0)
-static int parse_config_file (const char *filename, cfg_parse_flags_t flags)
+static int parse_config_file(const char *filename, cfg_parse_flags_t flags)
 {
-  int   rc = 0;
-  FILE *cfgfile;
-  char  line[1024];
-
-  cfgfile = fopen (filename, "r");
-  if (cfgfile == NULL)
-  {
-    err ("Can't open config file \"%s\" (%s)", filename, strerror (errno));
-    RETURN_FAILURE;
-  }
+    int rc = 0;
+    FILE *cfgfile;
+    char line[1024];
 
-  /* The first line of the configuration file must
-     contain exactly config_file_magic. */
-  if (fgets (line, sizeof line, cfgfile) == NULL
-     || memcmp (line, config_file_magic, sizeof config_file_magic - 1)
-     || line[sizeof config_file_magic - 1] != '\n'
-     || line[sizeof config_file_magic] != '\0')
-  {
-    if (flags & CFG_PARSE_MAGIC_ERROR)
+    cfgfile = fopen(filename, "r");
+    if (cfgfile == NULL)
     {
-      err ("%s(1): bad magic, not a valid Yadex configuration file", filename);
-      err ("Perhaps a leftover from a previous version of Yadex ?");
-      RETURN_FAILURE;
+	err("Can't open config file \"%s\" (%s)", filename, strerror(errno));
+	RETURN_FAILURE;
     }
-    if (flags & CFG_PARSE_MAGIC_WARN)
-      warn ("%s(1): bad magic, perhaps from a different version of Yadex\n",
-	  filename);
-    rewind (cfgfile);
-  }
 
-  // Execute one line on each iteration
-  for (unsigned lnum = 1; fgets (line, sizeof line, cfgfile) != NULL; lnum++)
-  {
-    char *name  = 0;
-    char *value = 0;
-    char *p     = line;
-
-    // Skip leading whitespace
-    while (isspace (*p))
-      p++;
-
-    // Skip comments
-    if (*p == '#')
-      continue;
-
-    // Remove trailing newline
+    /* The first line of the configuration file must
+       contain exactly config_file_magic. */
+    if (fgets(line, sizeof line, cfgfile) == NULL
+	|| memcmp(line, config_file_magic, sizeof config_file_magic - 1)
+	|| line[sizeof config_file_magic - 1] != '\n'
+	|| line[sizeof config_file_magic] != '\0')
     {
-      size_t len = strlen (p);
-      if (len >= 1 && p[len - 1] == '\n')
-	p[len - 1] = '\0';
+	if (flags & CFG_PARSE_MAGIC_ERROR)
+	{
+	    err("%s(1): bad magic, not a valid Yadex configuration file",
+		filename);
+	    err("Perhaps a leftover from a previous version of Yadex ?");
+	    RETURN_FAILURE;
+	}
+	if (flags & CFG_PARSE_MAGIC_WARN)
+	    warn("%s(1): bad magic, perhaps from a different version of Yadex\n", filename);
+	rewind(cfgfile);
     }
 
-    // Skip empty lines
-    if (*p == '\0')
-       continue;
-
-    // Make <name> point on the <name> field
-    name = p;
-    while (y_isident (*p))
-      p++;
-    if (*p == '\0')
+    // Execute one line on each iteration
+    for (unsigned lnum = 1; fgets(line, sizeof line, cfgfile) != NULL; lnum++)
     {
-      if (flags & CFG_PARSE_ANAL_SYNTAX)
-      {
-	err ("%s(%u): expected an \"=\"", filename, lnum);
-	RETURN_FAILURE;
-      }
-      else
-      {
-	warn ("%s(%u): expected an \"=\", skipping\n", filename, lnum);
-	goto next_line;
-      }
-    }
-    if (*p == '=')
-    {
-      // Mark the end of the option name
-      *p = '\0';
-    }
-    else
-    {
-      // Mark the end of the option name
-      *p = '\0';
-      p++;
-      // Skip blanks after the option name
-      while (isspace ((unsigned char) *p))
-	p++;
-      if (*p != '=')
-      {
-	if (flags & CFG_PARSE_ANAL_SYNTAX)
+	char *name = 0;
+	char *value = 0;
+	char *p = line;
+
+	// Skip leading whitespace
+	while (isspace(*p))
+	    p++;
+
+	// Skip comments
+	if (*p == '#')
+	    continue;
+
+	// Remove trailing newline
 	{
-	  err ("%s(%u,%d): expected an \"=\"",
-	    filename, lnum, 1 + (int) (p - line));
-	  RETURN_FAILURE;
+	    size_t len = strlen(p);
+	    if (len >= 1 && p[len - 1] == '\n')
+		p[len - 1] = '\0';
 	}
-	else
-	{
-	  warn ("%s(%u,%d): expected an \"=\", skipping\n",
-	    filename, lnum, 1 + (int) (p - line));
-	  goto next_line;
-	}
-      }
-    }
-    p++;
+
+	// Skip empty lines
+	if (*p == '\0')
+	    continue;
 
-    /* First parameter : <value> points on the first character.
-       Put a NUL at the end. If there is a second parameter,
-       holler. */
-    while (isspace ((unsigned char) *p))
-      p++;
-    value = p;
-    {
-      unsigned char *p2 = (unsigned char *) value;
-      while (*p2 != '\0' && ! isspace (*p2))
-	p2++;
-      if (*p2 != '\0')  // There's trailing whitespace after 1st parameter
-      {
-	for (unsigned char *p3 = p2; *p3 != '\0'; p3++)
-	  if (! isspace (*p3))
-	  {
-	    err ("%s(%u,%d): extraneous argument",
-	      filename, lnum, 1 + (int) ((char *) p3 - line));
-	    RETURN_FAILURE;
-	  }
-      }
-      *p2 = '\0';
-    }
-
-    for (const opt_desc_t *o = options + 1; ; o++)
-    {
-      if (o->opt_type == OPT_END)
-      {
-	if (flags & CFG_PARSE_ANAL_NAME)
+	// Make <name> point on the <name> field
+	name = p;
+	while (y_isident(*p))
+	    p++;
+	if (*p == '\0')
 	{
-	  err ("%s(%u): invalid variable \"%s\"", filename, lnum, name);
-	  RETURN_FAILURE;
+	    if (flags & CFG_PARSE_ANAL_SYNTAX)
+	    {
+		err("%s(%u): expected an \"=\"", filename, lnum);
+		RETURN_FAILURE;
+	    }
+	    else
+	    {
+		warn("%s(%u): expected an \"=\", skipping\n", filename, lnum);
+		goto next_line;
+	    }
+	}
+	if (*p == '=')
+	{
+	    // Mark the end of the option name
+	    *p = '\0';
 	}
 	else
 	{
-	  warn ("%s(%u): invalid variable \"%s\", skipping\n",
-	    filename, lnum, name);
-	  goto next_line;
+	    // Mark the end of the option name
+	    *p = '\0';
+	    p++;
+	    // Skip blanks after the option name
+	    while (isspace((unsigned char) *p))
+		p++;
+	    if (*p != '=')
+	    {
+		if (flags & CFG_PARSE_ANAL_SYNTAX)
+		{
+		    err("%s(%u,%d): expected an \"=\"",
+			filename, lnum, 1 + (int) (p - line));
+		    RETURN_FAILURE;
+		}
+		else
+		{
+		    warn("%s(%u,%d): expected an \"=\", skipping\n",
+			 filename, lnum, 1 + (int) (p - line));
+		    goto next_line;
+		}
+	    }
 	}
-      }
-      if (! o->long_name || strcmp (name, o->long_name) != 0)
-        continue;
+	p++;
 
-      if (o->flags != NULL && strchr (o->flags, '1'))
-	 break;
-#if ! defined Y_X11
-      if (o->flags != NULL && strchr (o->flags, 'x'))
-	 break;
-#endif
-      switch (o->opt_type)
-      {
-	case OPT_BOOLEAN:
-	  if (! strcmp (value, "yes") || ! strcmp (value, "true")
-	   || ! strcmp (value, "on") || ! strcmp (value, "1"))
-	  {
-	    if (o->data_ptr)
-	      *((bool *) (o->data_ptr)) = true;
-	  }
-	  else if (! strcmp (value, "no") || ! strcmp (value, "false")
-		|| ! strcmp (value, "off") || ! strcmp (value, "0"))
-	  {
-	    if (o->data_ptr)
-	      *((bool *) (o->data_ptr)) = false;
-	  }
-	  else
-	  {
-	    err ("%s(%u): invalid value for option %s: \"%s\"",
-	      filename, lnum, name, value);
-	    RETURN_FAILURE;
-	  }
-	  break;
+	/* First parameter : <value> points on the first character.
+	   Put a NUL at the end. If there is a second parameter,
+	   holler. */
+	while (isspace((unsigned char) *p))
+	    p++;
+	value = p;
+	{
+	    unsigned char *p2 = (unsigned char *) value;
+	    while (*p2 != '\0' && !isspace(*p2))
+		p2++;
+	    if (*p2 != '\0')	// There's trailing whitespace after 1st parameter
+	    {
+		for (unsigned char *p3 = p2; *p3 != '\0'; p3++)
+		    if (!isspace(*p3))
+		    {
+			err("%s(%u,%d): extraneous argument",
+			    filename, lnum, 1 + (int) ((char *) p3 - line));
+			RETURN_FAILURE;
+		    }
+	    }
+	    *p2 = '\0';
+	}
 
-	case OPT_CONFIRM:
-	  if (o->data_ptr)
-	    *((confirm_t *) o->data_ptr) = confirm_e2i (value);
-	  break;
-
-	case OPT_INTEGER:
-	  if (o->data_ptr)
-	    *((int *) (o->data_ptr)) = atoi (value);
-	  break;
-
-	case OPT_UNSIGNED:
-	  if (o->data_ptr)
-	  {
-	    if (*value == '\0')
+	for (const opt_desc_t * o = options + 1;; o++)
+	{
+	    if (o->opt_type == OPT_END)
 	    {
-	      err ("%s(%u,%d): missing argument",
-	        filename, lnum, 1 + (int) (value - line));
-	      RETURN_FAILURE;
-	    }
-	    bool neg = false;
-	    if (value[0] == '-')
-	      neg = true;
-	    char *endptr;
-	    errno = 0;
-	    *((unsigned long *) (o->data_ptr)) = strtoul (value, &endptr, 0);
-	    if (*endptr != '\0' && ! isspace (*endptr))
-	    {
-	      err ("%s(%u,%d): illegal character in unsigned integer",
-		filename, lnum, 1 + (int) (endptr - line));
-	      RETURN_FAILURE;
+		if (flags & CFG_PARSE_ANAL_NAME)
+		{
+		    err("%s(%u): invalid variable \"%s\"", filename, lnum,
+			name);
+		    RETURN_FAILURE;
+		}
+		else
+		{
+		    warn("%s(%u): invalid variable \"%s\", skipping\n",
+			 filename, lnum, name);
+		    goto next_line;
+		}
 	    }
-	    /* strtoul() sets errno to ERANGE if overflow. In
-	       addition, we don't want any non-zero negative
-	       numbers. In terms of regexp, /^(0x)?0*$/i. */
-	    if
-	    (
-	      errno != 0
-	      || neg
-	        && !
-		(
-		  strspn (value + 1, "0") == strlen (value + 1)
-		  || value[1] == '0'
-		    && tolower (value[2]) == 'x'
-		    && strspn (value + 3, "0") == strlen (value + 3)
-		)
-	    )
+	    if (!o->long_name || strcmp(name, o->long_name) != 0)
+		continue;
+
+	    if (o->flags != NULL && strchr(o->flags, '1'))
+		break;
+#if ! defined Y_X11
+	    if (o->flags != NULL && strchr(o->flags, 'x'))
+		break;
+#endif
+	    switch (o->opt_type)
 	    {
-	      err ("%s(%u,%d): unsigned integer out of range",
-		filename, lnum, 1 + (int) (value - line));
-	      RETURN_FAILURE;
-	    }
-	  }
-	  break;
+	    case OPT_BOOLEAN:
+		if (!strcmp(value, "yes") || !strcmp(value, "true")
+		    || !strcmp(value, "on") || !strcmp(value, "1"))
+		{
+		    if (o->data_ptr)
+			*((bool *) (o->data_ptr)) = true;
+		}
+		else if (!strcmp(value, "no") || !strcmp(value, "false")
+			 || !strcmp(value, "off") || !strcmp(value, "0"))
+		{
+		    if (o->data_ptr)
+			*((bool *) (o->data_ptr)) = false;
+		}
+		else
+		{
+		    err("%s(%u): invalid value for option %s: \"%s\"",
+			filename, lnum, name, value);
+		    RETURN_FAILURE;
+		}
+		break;
 
-	case OPT_WINDIM:
-	  if (o->data_ptr)
-	    if (((Win_dim *) (o->data_ptr))->set (value))
-	    {
-	      err ("%s(%u): bad dimension spec \"%s\"", filename, lnum, value);
-	      RETURN_FAILURE;
-	    }
-	  break;
+	    case OPT_CONFIRM:
+		if (o->data_ptr)
+		    *((confirm_t *) o->data_ptr) = confirm_e2i(value);
+		break;
 
-	case OPT_STRINGBUF8:
-	  if (o->data_ptr)
-	    al_scps ((char *) o->data_ptr, value, 8);
-	  break;
+	    case OPT_INTEGER:
+		if (o->data_ptr)
+		    *((int *) (o->data_ptr)) = atoi(value);
+		break;
 
-	case OPT_STRINGPTR:
-	  {
-	    char *dup = (char *) GetMemory (strlen (value) + 1);
-	    strcpy (dup, value);
-	    if (o->data_ptr)
-	      *((char **) (o->data_ptr)) = dup;
-	    break;
-	  }
+	    case OPT_UNSIGNED:
+		if (o->data_ptr)
+		{
+		    if (*value == '\0')
+		    {
+			err("%s(%u,%d): missing argument",
+			    filename, lnum, 1 + (int) (value - line));
+			RETURN_FAILURE;
+		    }
+		    bool neg = false;
+		    if (value[0] == '-')
+			neg = true;
+		    char *endptr;
+		    errno = 0;
+		    *((unsigned long *) (o->data_ptr)) =
+			strtoul(value, &endptr, 0);
+		    if (*endptr != '\0' && !isspace(*endptr))
+		    {
+			err("%s(%u,%d): illegal character in unsigned integer", filename, lnum, 1 + (int) (endptr - line));
+			RETURN_FAILURE;
+		    }
+		    /* strtoul() sets errno to ERANGE if overflow. In
+		       addition, we don't want any non-zero negative
+		       numbers. In terms of regexp, /^(0x)?0*$/i. */
+		    if (errno != 0
+			|| neg
+			&& !
+			(strspn(value + 1, "0") == strlen(value + 1)
+			 || value[1] == '0'
+			 && tolower(value[2]) == 'x'
+			 && strspn(value + 3, "0") == strlen(value + 3)))
+		    {
+			err("%s(%u,%d): unsigned integer out of range",
+			    filename, lnum, 1 + (int) (value - line));
+			RETURN_FAILURE;
+		    }
+		}
+		break;
 
-	case OPT_STRINGPTRACC:
-	  {
-	    char *dup = (char *) GetMemory (strlen (value) + 1);
-	    strcpy (dup, value);
-	    if (o->data_ptr)
-	      append_item_to_list ((const char ***) o->data_ptr, dup);
-	    break;
-	  }
+	    case OPT_WINDIM:
+		if (o->data_ptr)
+		    if (((Win_dim *) (o->data_ptr))->set(value))
+		    {
+			err("%s(%u): bad dimension spec \"%s\"", filename,
+			    lnum, value);
+			RETURN_FAILURE;
+		    }
+		break;
 
-	case OPT_STRINGPTRLIST:
-	  while (*value != '\0')
-	  {
-	    char *v = value;
-	    while (*v != '\0' && ! isspace ((unsigned char) *v))
-	      v++;
-	    char *dup = (char *) GetMemory (v - value + 1);
-	    memcpy (dup, value, v - value);
-	    dup[v - value] = '\0';
-	    if (o->data_ptr)
-	      append_item_to_list ((const char ***) o->data_ptr, dup);
-	    while (isspace (*v))
-	      v++;
-	    value = v;
-	  }
-	  break;
+	    case OPT_STRINGBUF8:
+		if (o->data_ptr)
+		    al_scps((char *) o->data_ptr, value, 8);
+		break;
+
+	    case OPT_STRINGPTR:
+		{
+		    char *dup = (char *) GetMemory(strlen(value) + 1);
+		    strcpy(dup, value);
+		    if (o->data_ptr)
+			*((char **) (o->data_ptr)) = dup;
+		    break;
+		}
+
+	    case OPT_STRINGPTRACC:
+		{
+		    char *dup = (char *) GetMemory(strlen(value) + 1);
+		    strcpy(dup, value);
+		    if (o->data_ptr)
+			append_item_to_list((const char ***) o->data_ptr,
+					    dup);
+		    break;
+		}
 
-	default:
-	  {
-	    nf_bug ("%s(%u): unknown option type %d",
-	      filename, lnum, (int) o->opt_type);
-	    RETURN_FAILURE;
-	  }
-      }
-      break;
+	    case OPT_STRINGPTRLIST:
+		while (*value != '\0')
+		{
+		    char *v = value;
+		    while (*v != '\0' && !isspace((unsigned char) *v))
+			v++;
+		    char *dup = (char *) GetMemory(v - value + 1);
+		    memcpy(dup, value, v - value);
+		    dup[v - value] = '\0';
+		    if (o->data_ptr)
+			append_item_to_list((const char ***) o->data_ptr,
+					    dup);
+		    while (isspace(*v))
+			v++;
+		    value = v;
+		}
+		break;
+
+	    default:
+		{
+		    nf_bug("%s(%u): unknown option type %d",
+			   filename, lnum, (int) o->opt_type);
+		    RETURN_FAILURE;
+		}
+	    }
+	    break;
+	}
+      next_line:;
     }
-    next_line:;
-  }
 
   byebye:
-  if (cfgfile != 0)
-    fclose (cfgfile);
-  return rc;
+    if (cfgfile != 0)
+	fclose(cfgfile);
+    return rc;
 }
 
 
@@ -940,205 +939,202 @@
  *	If an error occurs, report it with err()
  *	and returns non-zero. Else, returns 0.
  */
-int parse_command_line_options (int argc, const char *const *argv, int pass)
+int parse_command_line_options(int argc, const char *const *argv, int pass)
 {
-  const opt_desc_t *o;
-
-  while (argc > 0)
-  {
-    int ignore;
+    const opt_desc_t *o;
 
-    // Which option is this ?
-    if (**argv != '-' && **argv != '+')
+    while (argc > 0)
     {
-      o = options;
-      argc++;
-      argv--;
-    }
-    else
-      for (o = options + 1; ; o++)
-      {
-	if (o->opt_type == OPT_END)
+	int ignore;
+
+	// Which option is this ?
+	if (**argv != '-' && **argv != '+')
 	{
-	  err ("invalid option: \"%s\"", argv[0]);
-	  return 1;
-	}
-	if (o->short_name && ! strcmp (argv[0]+1, o->short_name)
-	 || o->long_name  && ! strcmp (argv[0]+1, o->long_name))
-	  break;
-      }
-
-    // If this option has the "1" flag but pass is not 1
-    // or it doesn't but pass is 1, ignore it.
-    ignore = (o->flags != NULL && strchr (o->flags, '1')) != (pass == 1);
-
-    switch (o->opt_type)
-    {
-      case OPT_BOOLEAN:
-	if (argv[0][0] == '-')
-	{
-	  if (o->data_ptr && ! ignore)
-	     *((bool *) (o->data_ptr)) = true;
+	    o = options;
+	    argc++;
+	    argv--;
 	}
 	else
-	{
-	  if (o->data_ptr && ! ignore)
-	     *((bool *) (o->data_ptr)) = false;
-	}
-	break;
+	    for (o = options + 1;; o++)
+	    {
+		if (o->opt_type == OPT_END)
+		{
+		    err("invalid option: \"%s\"", argv[0]);
+		    return 1;
+		}
+		if (o->short_name && !strcmp(argv[0] + 1, o->short_name)
+		    || o->long_name && !strcmp(argv[0] + 1, o->long_name))
+		    break;
+	    }
 
-      case OPT_CONFIRM:
-	if (argc <= 1)
+	// If this option has the "1" flag but pass is not 1
+	// or it doesn't but pass is 1, ignore it.
+	ignore = (o->flags != NULL && strchr(o->flags, '1')) != (pass == 1);
+
+	switch (o->opt_type)
 	{
-	  err ("missing argument after \"%s\"", argv[0]);
-	  return 1;
-	}
-	argv++;
-	argc--;
-	if (o->data_ptr && ! ignore)
-	   *((confirm_t *) o->data_ptr) = confirm_e2i (argv[0]);
-	break;
+	case OPT_BOOLEAN:
+	    if (argv[0][0] == '-')
+	    {
+		if (o->data_ptr && !ignore)
+		    *((bool *) (o->data_ptr)) = true;
+	    }
+	    else
+	    {
+		if (o->data_ptr && !ignore)
+		    *((bool *) (o->data_ptr)) = false;
+	    }
+	    break;
+
+	case OPT_CONFIRM:
+	    if (argc <= 1)
+	    {
+		err("missing argument after \"%s\"", argv[0]);
+		return 1;
+	    }
+	    argv++;
+	    argc--;
+	    if (o->data_ptr && !ignore)
+		*((confirm_t *) o->data_ptr) = confirm_e2i(argv[0]);
+	    break;
+
+	case OPT_INTEGER:
+	    if (argc <= 1)
+	    {
+		err("missing argument after \"%s\"", argv[0]);
+		return 1;
+	    }
+	    argv++;
+	    argc--;
+	    if (o->data_ptr && !ignore)
+		*((int *) (o->data_ptr)) = atoi(argv[0]);
+	    break;
 
-      case OPT_INTEGER:
-	if (argc <= 1)
-	{
-	  err ("missing argument after \"%s\"", argv[0]);
-	  return 1;
-	}
-	argv++;
-	argc--;
-	if (o->data_ptr && ! ignore)
-	  *((int *) (o->data_ptr)) = atoi (argv[0]);
-	break;
+	case OPT_UNSIGNED:
+	    if (argc <= 1)
+	    {
+		err("missing argument after \"%s\"", argv[0]);
+		return 1;
+	    }
+	    argv++;
+	    argc--;
+	    if (o->data_ptr && !ignore)
+	    {
+		const char *value = argv[0];
+		if (*value == '\0')
+		{
+		    err("not an unsigned integer \"%s\"", value);
+		    return 1;
+		}
+		bool neg = false;
+		if (*value == '-')
+		    neg = true;
+		char *endptr;
+		errno = 0;
+		*((unsigned long *) (o->data_ptr)) =
+		    strtoul(value, &endptr, 0);
+		while (*endptr != '\0' && isspace(*endptr))
+		    endptr++;
+		if (*endptr != '\0')
+		{
+		    err("illegal characters in unsigned int \"%s\"", endptr);
+		    return 1;
+		}
+		/* strtoul() sets errno to ERANGE if overflow. In
+		   addition, we don't want any non-zero negative
+		   numbers. In terms of regexp, /^(0x)?0*$/i. */
+		if (errno != 0
+		    || neg
+		    && !
+		    (strspn(value + 1, "0") == strlen(value + 1)
+		     || value[1] == '0'
+		     && tolower(value[2]) == 'x'
+		     && strspn(value + 3, "0") == strlen(value + 3)))
+		{
+		    err("unsigned integer out of range \"%s\"", value);
+		    return 1;
+		}
+	    }
+	    break;
 
-      case OPT_UNSIGNED:
-        if (argc <= 1)
-	{
-	  err ("missing argument after \"%s\"", argv[0]);
-	  return 1;
+	case OPT_WINDIM:
+	    if (argc <= 1)
+	    {
+		err("missing argument after \"%s\"", argv[0]);
+		return 1;
+	    }
+	    argv++;
+	    argc--;
+	    if (o->data_ptr && !ignore)
+		if (((Win_dim *) (o->data_ptr))->set(argv[0]))
+		{
+		    err("bad dimension spec \"%s\"", argv[0]);
+		    return 1;
+		}
+	    break;
+
+	case OPT_STRINGBUF8:
+	    if (argc <= 1)
+	    {
+		err("missing argument after \"%s\"", argv[0]);
+		return 1;
+	    }
+	    argv++;
+	    argc--;
+	    if (o->data_ptr && !ignore)
+		al_scps((char *) o->data_ptr, argv[0], 8);
+	    break;
+
+	case OPT_STRINGPTR:
+	    if (argc <= 1)
+	    {
+		err("missing argument after \"%s\"", argv[0]);
+		return 1;
+	    }
+	    argv++;
+	    argc--;
+	    if (o->data_ptr && !ignore)
+		*((const char **) (o->data_ptr)) = argv[0];
+	    break;
+
+	case OPT_STRINGPTRACC:
+	    if (argc <= 1)
+	    {
+		err("missing argument after \"%s\"", argv[0]);
+		return 1;
+	    }
+	    argv++;
+	    argc--;
+	    if (o->data_ptr && !ignore)
+		append_item_to_list((const char ***) o->data_ptr, argv[0]);
+	    break;
+
+	case OPT_STRINGPTRLIST:
+	    if (argc <= 1)
+	    {
+		err("missing argument after \"%s\"", argv[0]);
+		return 1;
+	    }
+	    while (argc > 1 && argv[1][0] != '-' && argv[1][0] != '+')
+	    {
+		argv++;
+		argc--;
+		if (o->data_ptr && !ignore)
+		    append_item_to_list((const char ***) o->data_ptr,
+					argv[0]);
+	    }
+	    break;
+
+	default:
+	    {
+		nf_bug("unknown option type (%d)", (int) o->opt_type);
+		return 1;
+	    }
 	}
 	argv++;
 	argc--;
-	if (o->data_ptr && ! ignore)
-	{
-	  const char *value = argv[0];
-	  if (*value == '\0')
-	  {
-	    err ("not an unsigned integer \"%s\"", value);
-	    return 1;
-	  }
-	  bool neg = false;
-	  if (*value == '-')
-	    neg = true;
-	  char *endptr;
-	  errno = 0;
-	  *((unsigned long *) (o->data_ptr)) = strtoul (value, &endptr, 0);
-	  while (*endptr != '\0' && isspace (*endptr))
-	    endptr++;
-	  if (*endptr != '\0')
-	  {
-	    err ("illegal characters in unsigned int \"%s\"", endptr);
-	    return 1;
-	  }
-	  /* strtoul() sets errno to ERANGE if overflow. In
-	     addition, we don't want any non-zero negative
-	     numbers. In terms of regexp, /^(0x)?0*$/i. */
-	  if
-	  (
-	    errno != 0
-	    || neg
-	      && !
-	      (
-		strspn (value + 1, "0") == strlen (value + 1)
-		|| value[1] == '0'
-		  && tolower (value[2]) == 'x'
-		  && strspn (value + 3, "0") == strlen (value + 3)
-	      )
-	  )
-	  {
-	    err ("unsigned integer out of range \"%s\"", value);
-	    return 1;
-	  }
-	}
-	break;
-
-      case OPT_WINDIM:
-	if (argc <= 1)
-	{
-	  err ("missing argument after \"%s\"", argv[0]);
-	  return 1;
-	}
-	argv++;
-	argc--;
-	if (o->data_ptr && ! ignore)
-	  if (((Win_dim *) (o->data_ptr))->set (argv[0]))
-	  {
-	    err ("bad dimension spec \"%s\"", argv[0]);
-	    return 1;
-	  }
-	break;
-
-      case OPT_STRINGBUF8:
-	if (argc <= 1)
-	{
-	  err ("missing argument after \"%s\"", argv[0]);
-	  return 1;
-	}
-	argv++;
-	argc--;
-	if (o->data_ptr && ! ignore)
-	  al_scps ((char *) o->data_ptr, argv[0], 8);
-	break;
-
-      case OPT_STRINGPTR:
-	if (argc <= 1)
-	{
-	  err ("missing argument after \"%s\"", argv[0]);
-	  return 1;
-	}
-	argv++;
-	argc--;
-	if (o->data_ptr && ! ignore)
-	  *((const char **) (o->data_ptr)) = argv[0];
-	break;
-
-      case OPT_STRINGPTRACC:
-	if (argc <= 1)
-	{
-	  err ("missing argument after \"%s\"", argv[0]);
-	  return 1;
-	}
-	argv++;
-	argc--;
-	if (o->data_ptr && ! ignore)
-	  append_item_to_list ((const char ***) o->data_ptr, argv[0]);
-	break;
-
-      case OPT_STRINGPTRLIST:
-	if (argc <= 1)
-	{
-	  err ("missing argument after \"%s\"", argv[0]);
-	  return 1;
-	}
-	while (argc > 1 && argv[1][0] != '-' && argv[1][0] != '+')
-	{
-	  argv++;
-	  argc--;
-	  if (o->data_ptr && ! ignore)
-	    append_item_to_list ((const char ***) o->data_ptr, argv[0]);
-	}
-	break;
-
-      default:
-	{
-	  nf_bug ("unknown option type (%d)", (int) o->opt_type);
-	  return 1;
-	}
     }
-    argv++;
-    argc--;
-  }
-  return 0;
+    return 0;
 }
 
 
@@ -1146,67 +1142,69 @@
  *	dump_parameters
  *	Print a list of the parameters with their current value.
  */
-void dump_parameters (FILE *fp)
+void dump_parameters(FILE * fp)
 {
-  const opt_desc_t *o;
-  int desc_maxlen = 0;
-  int name_maxlen = 0;
+    const opt_desc_t *o;
+    int desc_maxlen = 0;
+    int name_maxlen = 0;
 
-  for (o = options + 1; o->opt_type != OPT_END; o++)
-  {
-    int len = strlen (o->desc);
-    desc_maxlen = al_amax (desc_maxlen, len);
-    if (o->long_name)
+    for (o = options + 1; o->opt_type != OPT_END; o++)
     {
-      len = strlen (o->long_name);
-      name_maxlen = al_amax (name_maxlen, len);
+	int len = strlen(o->desc);
+	desc_maxlen = al_amax(desc_maxlen, len);
+	if (o->long_name)
+	{
+	    len = strlen(o->long_name);
+	    name_maxlen = al_amax(name_maxlen, len);
+	}
     }
-  }
 
-  for (o = options + 1; o->opt_type != OPT_END; o++)
-  {
-    if (! o->long_name)
-      continue;
-    fprintf (fp, "%-*s  %-*s  ",name_maxlen, o->long_name, desc_maxlen, o->desc);
-    if (o->opt_type == OPT_BOOLEAN)
-      fprintf (fp, "%s", *((bool *) o->data_ptr) ? "enabled" : "disabled");
-    else if (o->opt_type == OPT_CONFIRM)
-      fputs (confirm_i2e (*((confirm_t *) o->data_ptr)), fp);
-    else if (o->opt_type == OPT_STRINGBUF8)
-      fprintf (fp, "\"%s\"", (char *) o->data_ptr);
-    else if (o->opt_type == OPT_STRINGPTR)
+    for (o = options + 1; o->opt_type != OPT_END; o++)
     {
-      if (o->data_ptr)
-	fprintf (fp, "\"%s\"", *((char **) o->data_ptr));
-      else
-	fprintf (fp, "--none--");
-    }
-    else if (o->opt_type == OPT_INTEGER)
-      fprintf (fp, "%d", *((int *) o->data_ptr));
-    else if (o->opt_type == OPT_UNSIGNED)
-      fprintf (fp, "%lu", *((unsigned long *) o->data_ptr));
-    else if (o->opt_type == OPT_WINDIM)
-    {
-      char buf[50];  // Much slack
-      ((Win_dim *) (o->data_ptr))->string (buf, sizeof buf);
-      fputs (buf, fp);
+	if (!o->long_name)
+	    continue;
+	fprintf(fp, "%-*s  %-*s  ", name_maxlen, o->long_name, desc_maxlen,
+		o->desc);
+	if (o->opt_type == OPT_BOOLEAN)
+	    fprintf(fp, "%s",
+		    *((bool *) o->data_ptr) ? "enabled" : "disabled");
+	else if (o->opt_type == OPT_CONFIRM)
+	    fputs(confirm_i2e(*((confirm_t *) o->data_ptr)), fp);
+	else if (o->opt_type == OPT_STRINGBUF8)
+	    fprintf(fp, "\"%s\"", (char *) o->data_ptr);
+	else if (o->opt_type == OPT_STRINGPTR)
+	{
+	    if (o->data_ptr)
+		fprintf(fp, "\"%s\"", *((char **) o->data_ptr));
+	    else
+		fprintf(fp, "--none--");
+	}
+	else if (o->opt_type == OPT_INTEGER)
+	    fprintf(fp, "%d", *((int *) o->data_ptr));
+	else if (o->opt_type == OPT_UNSIGNED)
+	    fprintf(fp, "%lu", *((unsigned long *) o->data_ptr));
+	else if (o->opt_type == OPT_WINDIM)
+	{
+	    char buf[50];	// Much slack
+	    ((Win_dim *) (o->data_ptr))->string(buf, sizeof buf);
+	    fputs(buf, fp);
+	}
+	else if (o->opt_type == OPT_STRINGPTRACC
+		 || o->opt_type == OPT_STRINGPTRLIST)
+	{
+	    if (o->data_ptr)
+	    {
+		char **list;
+		for (list = *((char ***) o->data_ptr); list && *list; list++)
+		    fprintf(fp, "\"%s\" ", *list);
+		if (list == *((char ***) o->data_ptr))
+		    fprintf(fp, "--none--");
+	    }
+	    else
+		fprintf(fp, "--none--");
+	}
+	fputc('\n', fp);
     }
-    else if (o->opt_type == OPT_STRINGPTRACC
-	  || o->opt_type == OPT_STRINGPTRLIST)
-    {
-      if (o->data_ptr)
-      {
-	char **list;
-	for (list = *((char ***) o->data_ptr); list && *list; list++)
-	  fprintf (fp, "\"%s\" ", *list);
-	if (list == *((char ***) o->data_ptr))
-	  fprintf (fp, "--none--");
-      }
-      else
-	fprintf (fp, "--none--");
-    }
-    fputc ('\n', fp);
-  }
 }
 
 
@@ -1214,57 +1212,71 @@
  *	dump_command_line_options
  *	Print a list of all command line options (usage message).
  */
-void dump_command_line_options (FILE *fd)
+void dump_command_line_options(FILE * fd)
 {
-  const opt_desc_t *o;
-  int desc_maxlen = 0;
-  int name_maxlen = 0;
+    const opt_desc_t *o;
+    int desc_maxlen = 0;
+    int name_maxlen = 0;
 
-  for (o = options + 1; o->opt_type != OPT_END; o++)
-  {
-    int len;
-    if (! o->short_name)
-      continue;
-    len = strlen (o->desc);
-    desc_maxlen = al_amax (desc_maxlen, len);
-    if (o->long_name)
+    for (o = options + 1; o->opt_type != OPT_END; o++)
     {
-      len = strlen (o->long_name);
-      name_maxlen = al_amax (name_maxlen, len);
+	int len;
+	if (!o->short_name)
+	    continue;
+	len = strlen(o->desc);
+	desc_maxlen = al_amax(desc_maxlen, len);
+	if (o->long_name)
+	{
+	    len = strlen(o->long_name);
+	    name_maxlen = al_amax(name_maxlen, len);
+	}
     }
-  }
 
-  for (o = options; o->opt_type != OPT_END; o++)
-  {
-    if (! o->short_name)
-      continue;
+    for (o = options; o->opt_type != OPT_END; o++)
+    {
+	if (!o->short_name)
+	    continue;
 #if ! defined Y_X11
-    if (o->flags && strchr (o->flags, 'x'))
-      continue;
+	if (o->flags && strchr(o->flags, 'x'))
+	    continue;
 #endif
-    if (o->short_name)
-      fprintf (fd, " -%-3s ", o->short_name);
-    else
-      fprintf (fd, "      ");
-    if (o->long_name)
-      fprintf (fd, "-%-*s ", name_maxlen, o->long_name);
-    else
-      fprintf (fd, "%*s", name_maxlen + 2, "");
-    switch (o->opt_type)
-    {
-      case OPT_BOOLEAN:       fprintf (fd, "            "); break;
-      case OPT_CONFIRM:       fprintf (fd, "yes|no|ask  "); break;
-      case OPT_STRINGBUF8:
-      case OPT_STRINGPTR:
-      case OPT_STRINGPTRACC:  fprintf (fd, "<string>    "); break;
-      case OPT_INTEGER:       fprintf (fd, "<integer>   "); break;
-      case OPT_UNSIGNED:      fprintf (fd, "<unsigned>  "); break;
-      case OPT_WINDIM:        fprintf (fd, "<integer>[%%]"); break;
-      case OPT_STRINGPTRLIST: fprintf (fd, "<string> ..."); break;
-      case OPT_END: ;  // This line is here only to silence a GCC warning.
+	if (o->short_name)
+	    fprintf(fd, " -%-3s ", o->short_name);
+	else
+	    fprintf(fd, "      ");
+	if (o->long_name)
+	    fprintf(fd, "-%-*s ", name_maxlen, o->long_name);
+	else
+	    fprintf(fd, "%*s", name_maxlen + 2, "");
+	switch (o->opt_type)
+	{
+	case OPT_BOOLEAN:
+	    fprintf(fd, "            ");
+	    break;
+	case OPT_CONFIRM:
+	    fprintf(fd, "yes|no|ask  ");
+	    break;
+	case OPT_STRINGBUF8:
+	case OPT_STRINGPTR:
+	case OPT_STRINGPTRACC:
+	    fprintf(fd, "<string>    ");
+	    break;
+	case OPT_INTEGER:
+	    fprintf(fd, "<integer>   ");
+	    break;
+	case OPT_UNSIGNED:
+	    fprintf(fd, "<unsigned>  ");
+	    break;
+	case OPT_WINDIM:
+	    fprintf(fd, "<integer>[%%]");
+	    break;
+	case OPT_STRINGPTRLIST:
+	    fprintf(fd, "<string> ...");
+	    break;
+	case OPT_END:;		// This line is here only to silence a GCC warning.
+	}
+	fprintf(fd, " %s\n", o->desc);
     }
-    fprintf (fd, " %s\n", o->desc);
-  }
 }
 
 
@@ -1275,20 +1287,20 @@
  *	representation (YC_YES, YC_NO, YC_ASK, YC_ASK_ONCE or
  *	'\0' if none).
  */
-static confirm_t confirm_e2i (const char *external)
+static confirm_t confirm_e2i(const char *external)
 {
-  if (external != NULL)
-  {
-    if (! strcmp (external, "yes"))
-      return YC_YES;
-    if (! strcmp (external, "no"))
-      return YC_NO;
-    if (! strcmp (external, "ask"))
-      return YC_ASK;
-    if (! strcmp (external, "ask_once"))
-      return YC_ASK_ONCE;
-  }
-  return YC_ASK;
+    if (external != NULL)
+    {
+	if (!strcmp(external, "yes"))
+	    return YC_YES;
+	if (!strcmp(external, "no"))
+	    return YC_NO;
+	if (!strcmp(external, "ask"))
+	    return YC_ASK;
+	if (!strcmp(external, "ask_once"))
+	    return YC_ASK_ONCE;
+    }
+    return YC_ASK;
 }
 
 
@@ -1298,17 +1310,17 @@
  *	flag (YC_YES, YC_NO, YC_ASK, YC_ASK_ONCE) to the external
  *	representation ("yes", "no", "ask", "ask_once" or "?").
  */
-static const char *confirm_i2e (confirm_t internal)
+static const char *confirm_i2e(confirm_t internal)
 {
-  if (internal == YC_YES)
-    return "yes";
-  if (internal == YC_NO)
-    return "no";
-  if (internal == YC_ASK)
-    return "ask";
-  if (internal == YC_ASK_ONCE)
-    return "ask_once";
-  return "?";
+    if (internal == YC_YES)
+	return "yes";
+    if (internal == YC_NO)
+	return "no";
+    if (internal == YC_ASK)
+	return "ask";
+    if (internal == YC_ASK_ONCE)
+	return "ask_once";
+    return "?";
 }
 
 
@@ -1316,27 +1328,27 @@
  *	append_item_to_list
  *	Append a string to a null-terminated string list
  */
-static void append_item_to_list (const char ***list, const char *item)
+static void append_item_to_list(const char ***list, const char *item)
 {
-  int i;
+    int i;
 
-  i = 0;
-  if (*list != 0)
-  {
-    // Count the number of elements in the list (last = null)
-    while ((*list)[i] != 0)
-      i++;
-    // Expand the list
-    *list = (const char **) ResizeMemory (*list, (i + 2) * sizeof **list);
-  }
-  else
-  {
-    // Create a new list
-    *list = (const char **) GetMemory (2 * sizeof **list);
-  }
-  // Append the new element
-  (*list)[i] = item;
-  (*list)[i + 1] = 0;
+    i = 0;
+    if (*list != 0)
+    {
+	// Count the number of elements in the list (last = null)
+	while ((*list)[i] != 0)
+	    i++;
+	// Expand the list
+	*list = (const char **) ResizeMemory(*list, (i + 2) * sizeof **list);
+    }
+    else
+    {
+	// Create a new list
+	*list = (const char **) GetMemory(2 * sizeof **list);
+    }
+    // Append the new element
+    (*list)[i] = item;
+    (*list)[i + 1] = 0;
 }
 
 
@@ -1348,51 +1360,49 @@
 /*
  *	word_splitting - perform word splitting on a string
  */
-int word_splitting (std::vector<std::string>& tokens, const char *string)
+int word_splitting(std::vector < std::string > &tokens, const char *string)
 {
-  size_t      ntokens     = 0;
-  const char *iptr        = string;
-  const char *token_start = 0;
-  bool        in_token    = false;
-  bool        quoted      = false;
+    size_t ntokens = 0;
+    const char *iptr = string;
+    const char *token_start = 0;
+    bool in_token = false;
+    bool quoted = false;
 
-  /* break the line into whitespace-separated tokens.
-     whitespace can be enclosed in double quotes. */
-  for (; ; iptr++)
-  {
-    if (*iptr == '\n' || *iptr == '\0')
-      break;
+    /* break the line into whitespace-separated tokens.
+       whitespace can be enclosed in double quotes. */
+    for (;; iptr++)
+    {
+	if (*iptr == '\n' || *iptr == '\0')
+	    break;
+
+	else if (*iptr == '"')
+	    quoted = !quoted;
 
-    else if (*iptr == '"')
-      quoted = ! quoted;
-
-    // "#" at the beginning of a token
-    else if (! in_token && ! quoted && *iptr == '#')
-      break;
+	// "#" at the beginning of a token
+	else if (!in_token && !quoted && *iptr == '#')
+	    break;
 
-    // First character of token
-    else if (! in_token && (quoted || ! isspace (*iptr)))
-    {
-      ntokens++;
-      if (ntokens > MAX_TOKENS)
-	return 2;  // Too many tokens
-      in_token = true;
+	// First character of token
+	else if (!in_token && (quoted || !isspace(*iptr)))
+	{
+	    ntokens++;
+	    if (ntokens > MAX_TOKENS)
+		return 2;	// Too many tokens
+	    in_token = true;
+	}
+
+	// First space between two tokens
+	else if (in_token && !quoted && isspace(*iptr))
+	{
+	    tokens.push_back(std::string(token_start, iptr - token_start));
+	    in_token = false;
+	}
     }
 
-    // First space between two tokens
-    else if (in_token && ! quoted && isspace (*iptr))
-    {
-      tokens.push_back (std::string (token_start, iptr - token_start));
-      in_token = false;
-    }
-  }
-  
-  if (in_token)
-    tokens.push_back (std::string (token_start, iptr - token_start));
+    if (in_token)
+	tokens.push_back(std::string(token_start, iptr - token_start));
 
-  if (quoted)
-    return 1;  // Unmatched double quote
-  return 0;
+    if (quoted)
+	return 1;		// Unmatched double quote
+    return 0;
 }
-
-
--- a/src/cfgfile.h	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/cfgfile.h	Sat Sep 24 14:16:04 2011 +0300
@@ -4,11 +4,9 @@
  */
 
 
-int parse_config_file_default ();
-int parse_config_file_user (const char *name);
-int  parse_command_line_options (int argc, const char *const *argv, int pass);
-void dump_parameters (FILE *fd);
-void dump_command_line_options (FILE *fd);
+int parse_config_file_default();
+int parse_config_file_user(const char *name);
+int parse_command_line_options(int argc, const char *const *argv, int pass);
+void dump_parameters(FILE * fd);
+void dump_command_line_options(FILE * fd);
 extern const char config_file_magic[];
-
-
--- a/src/checks.cc	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/checks.cc	Sat Sep 24 14:16:04 2011 +0300
@@ -41,7 +41,7 @@
 #include "selectn.h"
 
 
-static void CheckingObjects ();
+static void CheckingObjects();
 
 
 /*
@@ -49,43 +49,42 @@
  *	check the level consistency
  *	FIXME should be integrated into editloop.cc
  */
-void CheckLevel (int x0, int y0) /* SWAP! */
+void CheckLevel(int x0, int y0)	/* SWAP! */
 {
-const char *line5 = 0;
+    const char *line5 = 0;
 
-if (Registered)
-   {
-   /* Commented out AYM 19971130 - wouldn't work with Doom 2
-   if (! FindMasterDir (MasterDir, "TEXTURE2"))
-      NumVertexes--;
-   else
-   */
-      line5 = "Check texture names";
-   }
-switch (vDisplayMenu (x0, y0, "Check level consistency",
-                     "Number of objects",		YK_, 0,
-                     "Check if all Sectors are closed",	YK_, 0,
-                     "Check all cross-references",	YK_, 0,
-                     "Check for missing textures",	YK_, 0,
-                     line5,				YK_, 0,
-                     NULL))
-   {
-   case 1:
-      Statistics ();
-      break;
-   case 2:
-      CheckSectors ();
-      break;
-   case 3:
-      CheckCrossReferences ();
-      break;
-   case 4:
-      CheckTextures ();
-      break;
-   case 5:
-      CheckTextureNames ();
-      break;
-   }
+    if (Registered)
+    {
+	/* Commented out AYM 19971130 - wouldn't work with Doom 2
+	   if (! FindMasterDir (MasterDir, "TEXTURE2"))
+	   NumVertexes--;
+	   else
+	 */
+	line5 = "Check texture names";
+    }
+    switch (vDisplayMenu(x0, y0, "Check level consistency",
+			 "Number of objects", YK_, 0,
+			 "Check if all Sectors are closed", YK_, 0,
+			 "Check all cross-references", YK_, 0,
+			 "Check for missing textures", YK_, 0,
+			 line5, YK_, 0, NULL))
+    {
+    case 1:
+	Statistics();
+	break;
+    case 2:
+	CheckSectors();
+	break;
+    case 3:
+	CheckCrossReferences();
+	break;
+    case 4:
+	CheckTextures();
+	break;
+    case 5:
+	CheckTextureNames();
+	break;
+    }
 }
 
 
@@ -93,65 +92,70 @@
    display number of objects, etc.
 */
 
-void Statistics ()
+void Statistics()
 {
-int height;
-int width;
-int out_x0;
-int out_y0;
-int text_x0;
-int text_y0;
+    int height;
+    int width;
+    int out_x0;
+    int out_y0;
+    int text_x0;
+    int text_y0;
 
-width  = 2 * BOX_BORDER + 2 * WIDE_HSPACING + 33 * FONTW;
-height = 2 * BOX_BORDER + 2 * WIDE_VSPACING + 9 * FONTH;
-out_x0 = (ScrMaxX + 1 - width) / 2;
-out_y0 = (ScrMaxY + 1 - height) / 2;
-text_x0 = out_x0 + BOX_BORDER + WIDE_HSPACING;
-text_y0 = out_y0 + BOX_BORDER + WIDE_VSPACING;
-DrawScreenBox3D (out_x0, out_y0, out_x0 + width - 1, out_y0 + height - 1);
-set_colour (WHITE);
-DrawScreenText (text_x0, text_y0, "Statistics");
-DrawScreenText (-1, -1, "");
+    width = 2 * BOX_BORDER + 2 * WIDE_HSPACING + 33 * FONTW;
+    height = 2 * BOX_BORDER + 2 * WIDE_VSPACING + 9 * FONTH;
+    out_x0 = (ScrMaxX + 1 - width) / 2;
+    out_y0 = (ScrMaxY + 1 - height) / 2;
+    text_x0 = out_x0 + BOX_BORDER + WIDE_HSPACING;
+    text_y0 = out_y0 + BOX_BORDER + WIDE_VSPACING;
+    DrawScreenBox3D(out_x0, out_y0, out_x0 + width - 1, out_y0 + height - 1);
+    set_colour(WHITE);
+    DrawScreenText(text_x0, text_y0, "Statistics");
+    DrawScreenText(-1, -1, "");
 
-if (! Things)
-   set_colour (WINFG_DIM);
-else
-   set_colour (WINFG);
-DrawScreenText (-1, -1, "Number of things:   %4d (%lu K)", NumThings,
- ((unsigned long) NumThings * sizeof (struct Thing) + 512L) / 1024L);
+    if (!Things)
+	set_colour(WINFG_DIM);
+    else
+	set_colour(WINFG);
+    DrawScreenText(-1, -1, "Number of things:   %4d (%lu K)", NumThings,
+		   ((unsigned long) NumThings * sizeof(struct Thing) +
+		    512L) / 1024L);
 
-if (! Vertices)
-   set_colour (WINFG_DIM);
-else
-   set_colour (WINFG);
-DrawScreenText (-1, -1, "Number of vertices: %4d (%lu K)", NumVertices,
- ((unsigned long) NumVertices * sizeof (struct Vertex) + 512L) / 1024L);
+    if (!Vertices)
+	set_colour(WINFG_DIM);
+    else
+	set_colour(WINFG);
+    DrawScreenText(-1, -1, "Number of vertices: %4d (%lu K)", NumVertices,
+		   ((unsigned long) NumVertices * sizeof(struct Vertex) +
+		    512L) / 1024L);
 
-if (! LineDefs)
-   set_colour (WINFG_DIM);
-else
-   set_colour (WINFG);
-DrawScreenText (-1, -1, "Number of linedefs: %4d (%lu K)", NumLineDefs,
- ((unsigned long) NumLineDefs * sizeof (struct LineDef) + 512L) / 1024L);
+    if (!LineDefs)
+	set_colour(WINFG_DIM);
+    else
+	set_colour(WINFG);
+    DrawScreenText(-1, -1, "Number of linedefs: %4d (%lu K)", NumLineDefs,
+		   ((unsigned long) NumLineDefs * sizeof(struct LineDef) +
+		    512L) / 1024L);
 
-if (! SideDefs)
-   set_colour (WINFG_DIM);
-else
-   set_colour (WINFG);
-DrawScreenText (-1, -1, "Number of sidedefs: %4d (%lu K)", NumSideDefs,
- ((unsigned long) NumSideDefs * sizeof (struct SideDef) + 512L) / 1024L);
+    if (!SideDefs)
+	set_colour(WINFG_DIM);
+    else
+	set_colour(WINFG);
+    DrawScreenText(-1, -1, "Number of sidedefs: %4d (%lu K)", NumSideDefs,
+		   ((unsigned long) NumSideDefs * sizeof(struct SideDef) +
+		    512L) / 1024L);
 
-if (! Sectors)
-   set_colour (WINFG_DIM);
-else
-   set_colour (WINFG);
-DrawScreenText (-1, -1, "Number of sectors:  %4d (%lu K)", NumSectors,
- ((unsigned long) NumSectors * sizeof (struct Sector) + 512L) / 1024L);
+    if (!Sectors)
+	set_colour(WINFG_DIM);
+    else
+	set_colour(WINFG);
+    DrawScreenText(-1, -1, "Number of sectors:  %4d (%lu K)", NumSectors,
+		   ((unsigned long) NumSectors * sizeof(struct Sector) +
+		    512L) / 1024L);
 
-DrawScreenText (-1, -1, "");
-set_colour (WINTITLE);
-DrawScreenText (-1, -1, "Press any key to continue...");
-get_key_or_click ();
+    DrawScreenText(-1, -1, "");
+    set_colour(WINTITLE);
+    DrawScreenText(-1, -1, "Press any key to continue...");
+    get_key_or_click();
 }
 
 
@@ -159,9 +163,9 @@
    display a message while the user is waiting...
 */
 
-static void CheckingObjects ()
+static void CheckingObjects()
 {
-DisplayMessage (-1, -1, "Grinding...");
+    DisplayMessage(-1, -1, "Grinding...");
 }
 
 
@@ -169,68 +173,69 @@
    display a message, then ask if the check should continue (prompt2 may be NULL)
 */
 
-bool CheckFailed (int x0, int y0, char *prompt1, char *prompt2, bool fatal,
-    bool &first_time)
+bool CheckFailed(int x0, int y0, char *prompt1, char *prompt2, bool fatal,
+		 bool & first_time)
 {
-int key;
-size_t maxlen;
+    int key;
+    size_t maxlen;
 
-if (fatal)
-   maxlen = 44;
-else
-   maxlen = 27;
-if (strlen (prompt1) > maxlen)
-   maxlen = strlen (prompt1);
-if (prompt2 && strlen (prompt2) > maxlen)
-   maxlen = strlen (prompt2);
-int width = 2 * BOX_BORDER + 2 * WIDE_HSPACING + FONTW * maxlen;
-int height = 2 * BOX_BORDER + 2 * WIDE_VSPACING + FONTH * (prompt2 ? 6 : 5);
-if (x0 < 0)
-   x0 = (ScrMaxX - width) / 2;
-if (y0 < 0)
-   y0 = (ScrMaxY - height) / 2;
-int text_x0 = x0 + BOX_BORDER + WIDE_HSPACING;
-int text_y0 = y0 + BOX_BORDER + WIDE_VSPACING;
-int cur_y = text_y0;
-DrawScreenBox3D (x0, y0, x0 + width - 1, y0 + height - 1);
-set_colour (LIGHTRED);
-DrawScreenText (text_x0, cur_y, "Verification failed:");
-if (first_time)
-   Beep ();
-set_colour (WHITE);
-DrawScreenText (text_x0, cur_y += FONTH, prompt1);
-LogMessage ("\t%s\n", prompt1);
-if (prompt2)
-   {
-   DrawScreenText (text_x0, cur_y += FONTH, prompt2);
-   LogMessage ("\t%s\n", prompt2);
-   }
-if (fatal)
-   {
-   DrawScreenText (text_x0, cur_y += 2 * FONTH,
-     "The game will crash if you play with this level.");
-   set_colour (WINTITLE);
-   DrawScreenText (text_x0, cur_y += FONTH,
-     "Press any key to see the object");
-   LogMessage ("\n");
-   }
-else
-   {
-   set_colour (WINTITLE);
-   DrawScreenText (text_x0, cur_y += 2 * FONTH,
-     "Press Esc to see the object,");
-   DrawScreenText (text_x0, cur_y += FONTH,
-     "or any other key to continue");
-   }
-key = get_key ();
-if (key != YK_ESC)
-   {
-   DrawScreenBox3D (x0, y0, x0 + width - 1, y0 + height - 1);
+    if (fatal)
+	maxlen = 44;
+    else
+	maxlen = 27;
+    if (strlen(prompt1) > maxlen)
+	maxlen = strlen(prompt1);
+    if (prompt2 && strlen(prompt2) > maxlen)
+	maxlen = strlen(prompt2);
+    int width = 2 * BOX_BORDER + 2 * WIDE_HSPACING + FONTW * maxlen;
+    int height =
+	2 * BOX_BORDER + 2 * WIDE_VSPACING + FONTH * (prompt2 ? 6 : 5);
+    if (x0 < 0)
+	x0 = (ScrMaxX - width) / 2;
+    if (y0 < 0)
+	y0 = (ScrMaxY - height) / 2;
+    int text_x0 = x0 + BOX_BORDER + WIDE_HSPACING;
+    int text_y0 = y0 + BOX_BORDER + WIDE_VSPACING;
+    int cur_y = text_y0;
+    DrawScreenBox3D(x0, y0, x0 + width - 1, y0 + height - 1);
+    set_colour(LIGHTRED);
+    DrawScreenText(text_x0, cur_y, "Verification failed:");
+    if (first_time)
+	Beep();
+    set_colour(WHITE);
+    DrawScreenText(text_x0, cur_y += FONTH, prompt1);
+    LogMessage("\t%s\n", prompt1);
+    if (prompt2)
+    {
+	DrawScreenText(text_x0, cur_y += FONTH, prompt2);
+	LogMessage("\t%s\n", prompt2);
+    }
+    if (fatal)
+    {
+	DrawScreenText(text_x0, cur_y += 2 * FONTH,
+		       "The game will crash if you play with this level.");
+	set_colour(WINTITLE);
+	DrawScreenText(text_x0, cur_y += FONTH,
+		       "Press any key to see the object");
+	LogMessage("\n");
+    }
+    else
+    {
+	set_colour(WINTITLE);
+	DrawScreenText(text_x0, cur_y += 2 * FONTH,
+		       "Press Esc to see the object,");
+	DrawScreenText(text_x0, cur_y += FONTH,
+		       "or any other key to continue");
+    }
+    key = get_key();
+    if (key != YK_ESC)
+    {
+	DrawScreenBox3D(x0, y0, x0 + width - 1, y0 + height - 1);
 //   DrawScreenText (x0 + 10 + 4 * (maxlen - 26), y0 + 28,
 //      "Verifying other objects...");
-   }
-first_time = false;
-return (key == YK_ESC);
+    }
+    first_time = false;
+    return (key == YK_ESC);
 }
 
 
@@ -238,64 +243,65 @@
    check if all sectors are closed
 */
 
-void CheckSectors () /* SWAP! */
+void CheckSectors()		/* SWAP! */
 {
-int        s, n, sd;
-char *ends;
-char       msg1[80], msg2[80];
-bool       first_time = true;
+    int s, n, sd;
+    char *ends;
+    char msg1[80], msg2[80];
+    bool first_time = true;
 
-CheckingObjects ();
-LogMessage ("\nVerifying Sectors...\n");
-ends = (char *) GetMemory (NumVertices);
-for (s = 0; s < NumSectors; s++)
-   {
-   /* clear the "ends" array */
-   for (n = 0; n < NumVertices; n++)
-      ends[n] = 0;
-   /* for each sidedef bound to the Sector, store a "1" in the "ends" */
-   /* array for its starting Vertex, and a "2" for its ending Vertex  */
-   for (n = 0; n < NumLineDefs; n++)
-      {
-      sd = LineDefs[n].sidedef1;
-      if (sd >= 0 && SideDefs[sd].sector == s)
-	 {
-	 ends[LineDefs[n].start] |= 1;
-	 ends[LineDefs[n].end] |= 2;
-	 }
-      sd = LineDefs[n].sidedef2;
-      if (sd >= 0 && SideDefs[sd].sector == s)
-	 {
-	 ends[LineDefs[n].end] |= 1;
-	 ends[LineDefs[n].start] |= 2;
-	 }
-      }
-   /* every entry in the "ends" array should be "0" or "3" */
-   for (n = 0; n < NumVertices; n++)
-      {
-      if (ends[n] == 1)
-	 {
-	 sprintf (msg1, "Sector #%d is not closed!", s);
-	 sprintf (msg2, "There is no sidedef ending at Vertex #%d", n);
-	 if (CheckFailed (-1, -1, msg1, msg2, 0, first_time))
+    CheckingObjects();
+    LogMessage("\nVerifying Sectors...\n");
+    ends = (char *) GetMemory(NumVertices);
+    for (s = 0; s < NumSectors; s++)
+    {
+	/* clear the "ends" array */
+	for (n = 0; n < NumVertices; n++)
+	    ends[n] = 0;
+	/* for each sidedef bound to the Sector, store a "1" in the "ends" */
+	/* array for its starting Vertex, and a "2" for its ending Vertex  */
+	for (n = 0; n < NumLineDefs; n++)
+	{
+	    sd = LineDefs[n].sidedef1;
+	    if (sd >= 0 && SideDefs[sd].sector == s)
+	    {
+		ends[LineDefs[n].start] |= 1;
+		ends[LineDefs[n].end] |= 2;
+	    }
+	    sd = LineDefs[n].sidedef2;
+	    if (sd >= 0 && SideDefs[sd].sector == s)
 	    {
-	    GoToObject (Objid (OBJ_VERTICES, n));
-	    return;
+		ends[LineDefs[n].end] |= 1;
+		ends[LineDefs[n].start] |= 2;
 	    }
-	 }
-      if (ends[n] == 2)
-	 {
-	 sprintf (msg1, "Sector #%d is not closed!", s);
-	 sprintf (msg2, "There is no sidedef starting at Vertex #%d", n);
-	 if (CheckFailed (-1, -1, msg1, msg2, 0, first_time))
+	}
+	/* every entry in the "ends" array should be "0" or "3" */
+	for (n = 0; n < NumVertices; n++)
+	{
+	    if (ends[n] == 1)
 	    {
-	    GoToObject (Objid (OBJ_VERTICES, n));
-	    return;
+		sprintf(msg1, "Sector #%d is not closed!", s);
+		sprintf(msg2, "There is no sidedef ending at Vertex #%d", n);
+		if (CheckFailed(-1, -1, msg1, msg2, 0, first_time))
+		{
+		    GoToObject(Objid(OBJ_VERTICES, n));
+		    return;
+		}
 	    }
-	 }
-      }
-   }
-FreeMemory (ends);
+	    if (ends[n] == 2)
+	    {
+		sprintf(msg1, "Sector #%d is not closed!", s);
+		sprintf(msg2, "There is no sidedef starting at Vertex #%d",
+			n);
+		if (CheckFailed(-1, -1, msg1, msg2, 0, first_time))
+		{
+		    GoToObject(Objid(OBJ_VERTICES, n));
+		    return;
+		}
+	    }
+	}
+    }
+    FreeMemory(ends);
 
 /*
    Note from RQ:
@@ -314,59 +320,63 @@
 */
 
 /* now check if all SideDefs are facing a sidedef with the same Sector number */
-for (n = 0; n < NumLineDefs; n++)
-   {
-   sd = LineDefs[n].sidedef1;
-   if (sd >= 0)
-      {
-      s = GetOppositeSector (n, 1);
-      if (s < 0 || SideDefs[sd].sector != s)
-	 {
-	 if (s < 0)
+    for (n = 0; n < NumLineDefs; n++)
+    {
+	sd = LineDefs[n].sidedef1;
+	if (sd >= 0)
+	{
+	    s = GetOppositeSector(n, 1);
+	    if (s < 0 || SideDefs[sd].sector != s)
 	    {
-	    sprintf (msg1, "Sector #%d is not closed!", SideDefs[sd].sector);
-	    sprintf (msg2, "Check linedef #%d (first sidedef: #%d)", n, sd);
-	    }
-	 else
-	    {
-	    sprintf (msg1, "Sectors #%d and #%d are not closed!",
-	       SideDefs[sd].sector, s);
-	    sprintf (msg2, "Check linedef #%d (first sidedef: #%d)"
-	       " and the one facing it", n, sd);
-	    }
-	 if (CheckFailed (-1, -1, msg1, msg2, 0, first_time))
-	    {
-	    GoToObject (Objid (OBJ_LINEDEFS, n));
-	    return;
+		if (s < 0)
+		{
+		    sprintf(msg1, "Sector #%d is not closed!",
+			    SideDefs[sd].sector);
+		    sprintf(msg2, "Check linedef #%d (first sidedef: #%d)", n,
+			    sd);
+		}
+		else
+		{
+		    sprintf(msg1, "Sectors #%d and #%d are not closed!",
+			    SideDefs[sd].sector, s);
+		    sprintf(msg2, "Check linedef #%d (first sidedef: #%d)"
+			    " and the one facing it", n, sd);
+		}
+		if (CheckFailed(-1, -1, msg1, msg2, 0, first_time))
+		{
+		    GoToObject(Objid(OBJ_LINEDEFS, n));
+		    return;
+		}
 	    }
-	 }
-      }
-   sd = LineDefs[n].sidedef2;
-   if (sd >= 0)
-      {
-      s = GetOppositeSector (n, 0);
-      if (s < 0 || SideDefs[sd].sector != s)
-	 {
-	 if (s < 0)
+	}
+	sd = LineDefs[n].sidedef2;
+	if (sd >= 0)
+	{
+	    s = GetOppositeSector(n, 0);
+	    if (s < 0 || SideDefs[sd].sector != s)
 	    {
-	    sprintf (msg1, "Sector #%d is not closed!", SideDefs[sd].sector);
-	    sprintf (msg2, "Check linedef #%d (second sidedef: #%d)", n, sd);
+		if (s < 0)
+		{
+		    sprintf(msg1, "Sector #%d is not closed!",
+			    SideDefs[sd].sector);
+		    sprintf(msg2, "Check linedef #%d (second sidedef: #%d)",
+			    n, sd);
+		}
+		else
+		{
+		    sprintf(msg1, "Sectors #%d and #%d are not closed!",
+			    SideDefs[sd].sector, s);
+		    sprintf(msg2, "Check linedef #%d (second sidedef: #%d)"
+			    " and the one facing it", n, sd);
+		}
+		if (CheckFailed(-1, -1, msg1, msg2, 0, first_time))
+		{
+		    GoToObject(Objid(OBJ_LINEDEFS, n));
+		    return;
+		}
 	    }
-	 else
-	    {
-	    sprintf (msg1, "Sectors #%d and #%d are not closed!",
-	       SideDefs[sd].sector, s);
-	    sprintf (msg2, "Check linedef #%d (second sidedef: #%d)"
-	       " and the one facing it", n, sd);
-	    }
-	 if (CheckFailed (-1, -1, msg1, msg2, 0, first_time))
-	    {
-	    GoToObject (Objid (OBJ_LINEDEFS, n));
-	    return;
-	    }
-	 }
-      }
-   }
+	}
+    }
 }
 
 
@@ -374,203 +384,209 @@
    check cross-references and delete unused objects
 */
 
-void CheckCrossReferences () /* SWAP! */
+void CheckCrossReferences()	/* SWAP! */
 {
-char   msg[80];
-int    n, m;
-SelPtr cur;
-bool   first_time = true;
+    char msg[80];
+    int n, m;
+    SelPtr cur;
+    bool first_time = true;
 
-CheckingObjects ();
-LogMessage ("\nVerifying cross-references...\n");
-for (n = 0; n < NumLineDefs; n++)
-   {
-   /* Check for missing first sidedefs */
-   if (LineDefs[n].sidedef1 < 0)
-      {
-      sprintf (msg, "ERROR: linedef #%d has no first sidedef!", n);
-      CheckFailed (-1, -1, msg, 0, 1, first_time);
-      GoToObject (Objid (OBJ_LINEDEFS, n));
-      return;
-      }
+    CheckingObjects();
+    LogMessage("\nVerifying cross-references...\n");
+    for (n = 0; n < NumLineDefs; n++)
+    {
+	/* Check for missing first sidedefs */
+	if (LineDefs[n].sidedef1 < 0)
+	{
+	    sprintf(msg, "ERROR: linedef #%d has no first sidedef!", n);
+	    CheckFailed(-1, -1, msg, 0, 1, first_time);
+	    GoToObject(Objid(OBJ_LINEDEFS, n));
+	    return;
+	}
 
 // FIXME should make this a mere warning
-#ifdef OLD  /* ifdef'd out AYM 19970725, I do it and it works */
-   /* Check for sidedefs used twice in the same linedef */
-   if (LineDefs[n].sidedef1 == LineDefs[n].sidedef2)
-      {
-      sprintf (msg, "ERROR: linedef #%d uses the same sidedef twice (#%d)",
-	n, LineDefs[n].sidedef1);
-      CheckFailed (-1, -1, msg, 0, 1, first_time);
-      GoToObject (Objid (OBJ_LINEDEFS, n));
-      return;
-      }
+#ifdef OLD			/* ifdef'd out AYM 19970725, I do it and it works */
+	/* Check for sidedefs used twice in the same linedef */
+	if (LineDefs[n].sidedef1 == LineDefs[n].sidedef2)
+	{
+	    sprintf(msg,
+		    "ERROR: linedef #%d uses the same sidedef twice (#%d)", n,
+		    LineDefs[n].sidedef1);
+	    CheckFailed(-1, -1, msg, 0, 1, first_time);
+	    GoToObject(Objid(OBJ_LINEDEFS, n));
+	    return;
+	}
 #endif
 
-   /* Check for vertices used twice in the same linedef */
-   if (LineDefs[n].start == LineDefs[n].end)
-      {
-      sprintf (msg, "ERROR: linedef #%d uses the same vertex twice (#%d)",
-	n, LineDefs[n].start);
-      CheckFailed (-1, -1, msg, 0, 1, first_time);
-      GoToObject (Objid (OBJ_LINEDEFS, n));
-      return;
-      }
-   }
+	/* Check for vertices used twice in the same linedef */
+	if (LineDefs[n].start == LineDefs[n].end)
+	{
+	    sprintf(msg,
+		    "ERROR: linedef #%d uses the same vertex twice (#%d)", n,
+		    LineDefs[n].start);
+	    CheckFailed(-1, -1, msg, 0, 1, first_time);
+	    GoToObject(Objid(OBJ_LINEDEFS, n));
+	    return;
+	}
+    }
 
 /* check if there aren't two linedefs between the same Vertices */
-cur = 0;
+    cur = 0;
 /* AYM 19980203 FIXME should use new algorithm */
-for (n = NumLineDefs - 1; n >= 1; n--)
-   {
-   for (m = n - 1; m >= 0; m--)
-      if ((LineDefs[n].start == LineDefs[m].start
-	&& LineDefs[n].end   == LineDefs[m].end)
-       || (LineDefs[n].start == LineDefs[m].end
-	&& LineDefs[n].end   == LineDefs[m].start))
-          {
-	  SelectObject (&cur, n);
-	  break;
-          }
-   }
-if (cur
-  && (Expert
-   || Confirm (-1, -1, "There are multiple linedefs between the same vertices",
-	   "Do you want to delete the redundant linedefs?")))
-   DeleteObjects (OBJ_LINEDEFS, &cur);
-else
-   ForgetSelection (&cur);
+    for (n = NumLineDefs - 1; n >= 1; n--)
+    {
+	for (m = n - 1; m >= 0; m--)
+	    if ((LineDefs[n].start == LineDefs[m].start
+		 && LineDefs[n].end == LineDefs[m].end)
+		|| (LineDefs[n].start == LineDefs[m].end
+		    && LineDefs[n].end == LineDefs[m].start))
+	    {
+		SelectObject(&cur, n);
+		break;
+	    }
+    }
+    if (cur
+	&& (Expert
+	    || Confirm(-1, -1,
+		       "There are multiple linedefs between the same vertices",
+		       "Do you want to delete the redundant linedefs?")))
+	DeleteObjects(OBJ_LINEDEFS, &cur);
+    else
+	ForgetSelection(&cur);
 
-CheckingObjects ();
+    CheckingObjects();
 /* check for invalid flags in the linedefs */
-for (n = 0; n < NumLineDefs; n++)
-   if ((LineDefs[n].flags & 0x01) == 0 && LineDefs[n].sidedef2 < 0)
-      SelectObject (&cur, n);
-if (cur && (Expert
-    || Confirm (-1, -1, "Some linedefs have only one side but their I flag is"
-	" not set",
-        "Do you want to set the 'Impassible' flag?")))
-   while (cur)
-      {
-      LogMessage  ("Check: 1-sided linedef without I flag: %d", cur->objnum);
-      LineDefs[cur->objnum].flags |= 0x01;
-      UnSelectObject (&cur, cur->objnum);
-      }
-else
-   ForgetSelection (&cur);
+    for (n = 0; n < NumLineDefs; n++)
+	if ((LineDefs[n].flags & 0x01) == 0 && LineDefs[n].sidedef2 < 0)
+	    SelectObject(&cur, n);
+    if (cur && (Expert
+		|| Confirm(-1, -1,
+			   "Some linedefs have only one side but their I flag is"
+			   " not set",
+			   "Do you want to set the 'Impassible' flag?")))
+	while (cur)
+	{
+	    LogMessage("Check: 1-sided linedef without I flag: %d",
+		       cur->objnum);
+	    LineDefs[cur->objnum].flags |= 0x01;
+	    UnSelectObject(&cur, cur->objnum);
+	}
+    else
+	ForgetSelection(&cur);
 
-CheckingObjects ();
-for (n = 0; n < NumLineDefs; n++)
-   if ((LineDefs[n].flags & 0x04) != 0 && LineDefs[n].sidedef2 < 0)
-      SelectObject (&cur, n);
-if (cur
-  && (Expert
-      || Confirm (-1, -1, "Some linedefs have only one side but their 2 flag"
-	  " is set",
-	   "Do you want to clear the 'two-sided' flag?")))
-   {
-   while (cur)
-      {
-      LogMessage  ("Check: 1-sided linedef with 2s bit: %d", cur->objnum);
-      LineDefs[cur->objnum].flags &= ~0x04;
-      UnSelectObject (&cur, cur->objnum);
-      }
-   }
-else
-   ForgetSelection (&cur);
+    CheckingObjects();
+    for (n = 0; n < NumLineDefs; n++)
+	if ((LineDefs[n].flags & 0x04) != 0 && LineDefs[n].sidedef2 < 0)
+	    SelectObject(&cur, n);
+    if (cur
+	&& (Expert
+	    || Confirm(-1, -1,
+		       "Some linedefs have only one side but their 2 flag"
+		       " is set",
+		       "Do you want to clear the 'two-sided' flag?")))
+    {
+	while (cur)
+	{
+	    LogMessage("Check: 1-sided linedef with 2s bit: %d", cur->objnum);
+	    LineDefs[cur->objnum].flags &= ~0x04;
+	    UnSelectObject(&cur, cur->objnum);
+	}
+    }
+    else
+	ForgetSelection(&cur);
 
-CheckingObjects ();
-for (n = 0; n < NumLineDefs; n++)
-   if ((LineDefs[n].flags & 0x04) == 0 && LineDefs[n].sidedef2 >= 0)
-      SelectObject (&cur, n);
-if (cur
-  && (Expert
-      || Confirm (-1, -1,
-	   "Some linedefs have two sides but their 2S bit is not set",
-	   "Do you want to set the 'two-sided' flag?")))
-   {
-   while (cur)
-      {
-      LineDefs[cur->objnum].flags |= 0x04;
-      UnSelectObject (&cur, cur->objnum);
-      }
-   }
-else
-   ForgetSelection (&cur);
+    CheckingObjects();
+    for (n = 0; n < NumLineDefs; n++)
+	if ((LineDefs[n].flags & 0x04) == 0 && LineDefs[n].sidedef2 >= 0)
+	    SelectObject(&cur, n);
+    if (cur
+	&& (Expert
+	    || Confirm(-1, -1,
+		       "Some linedefs have two sides but their 2S bit is not set",
+		       "Do you want to set the 'two-sided' flag?")))
+    {
+	while (cur)
+	{
+	    LineDefs[cur->objnum].flags |= 0x04;
+	    UnSelectObject(&cur, cur->objnum);
+	}
+    }
+    else
+	ForgetSelection(&cur);
 
-CheckingObjects ();
+    CheckingObjects();
 /* select all Vertices */
-for (n = 0; n < NumVertices; n++)
-   SelectObject (&cur, n);
+    for (n = 0; n < NumVertices; n++)
+	SelectObject(&cur, n);
 /* unselect Vertices used in a LineDef */
-for (n = 0; n < NumLineDefs; n++)
-   {
-   m = LineDefs[n].start;
-   if (cur && m >= 0)
-      UnSelectObject (&cur, m);
-   m = LineDefs[n].end;
-   if (cur && m >= 0)
-      UnSelectObject (&cur, m);
-   continue;
-   }
+    for (n = 0; n < NumLineDefs; n++)
+    {
+	m = LineDefs[n].start;
+	if (cur && m >= 0)
+	    UnSelectObject(&cur, m);
+	m = LineDefs[n].end;
+	if (cur && m >= 0)
+	    UnSelectObject(&cur, m);
+	continue;
+    }
 /* check if there are any Vertices left */
-if (cur
-  && (Expert
-     || Confirm (-1, -1, "Some vertices are not bound to any linedef",
-			"Do you want to delete these unused Vertices?")))
-   {
-   DeleteObjects (OBJ_VERTICES, &cur);
-   }
-else
-   ForgetSelection (&cur);
+    if (cur
+	&& (Expert
+	    || Confirm(-1, -1, "Some vertices are not bound to any linedef",
+		       "Do you want to delete these unused Vertices?")))
+    {
+	DeleteObjects(OBJ_VERTICES, &cur);
+    }
+    else
+	ForgetSelection(&cur);
 
-CheckingObjects ();
+    CheckingObjects();
 /* select all SideDefs */
-for (n = 0; n < NumSideDefs; n++)
-   SelectObject (&cur, n);
+    for (n = 0; n < NumSideDefs; n++)
+	SelectObject(&cur, n);
 /* unselect SideDefs bound to a LineDef */
-for (n = 0; n < NumLineDefs; n++)
-   {
-   m = LineDefs[n].sidedef1;
-   if (cur && m >= 0)
-      UnSelectObject (&cur, m);
-   m = LineDefs[n].sidedef2;
-   if (cur && m >= 0)
-      UnSelectObject (&cur, m);
-   continue;
-   }
+    for (n = 0; n < NumLineDefs; n++)
+    {
+	m = LineDefs[n].sidedef1;
+	if (cur && m >= 0)
+	    UnSelectObject(&cur, m);
+	m = LineDefs[n].sidedef2;
+	if (cur && m >= 0)
+	    UnSelectObject(&cur, m);
+	continue;
+    }
 /* check if there are any SideDefs left */
-if (cur
-  && (Expert
-      || Confirm (-1, -1, "Some sidedefs are not bound to any linedef",
-			 "Do you want to delete these unused sidedefs?")))
-   DeleteObjects (OBJ_SIDEDEFS, &cur);
-else
-   ForgetSelection (&cur);
+    if (cur
+	&& (Expert
+	    || Confirm(-1, -1, "Some sidedefs are not bound to any linedef",
+		       "Do you want to delete these unused sidedefs?")))
+	DeleteObjects(OBJ_SIDEDEFS, &cur);
+    else
+	ForgetSelection(&cur);
 
-CheckingObjects ();
+    CheckingObjects();
 /* select all Sectors */
-for (n = 0; n < NumSectors; n++)
-   SelectObject (&cur, n);
+    for (n = 0; n < NumSectors; n++)
+	SelectObject(&cur, n);
 /* unselect Sectors bound to a sidedef */
-for (n = 0; n < NumLineDefs; n++)
-   {
-   m = LineDefs[n].sidedef1;
-   if (cur && m >= 0 /* && SideDefs[m].sector >= 0 AYM 1998-06-13 */)
-      UnSelectObject (&cur, SideDefs[m].sector);
-   m = LineDefs[n].sidedef2;
-   if (cur && m >= 0 /* && SideDefs[m].sector >= 0 AYM 1998-06-13 */)
-      UnSelectObject (&cur, SideDefs[m].sector);
-   continue;
-   }
+    for (n = 0; n < NumLineDefs; n++)
+    {
+	m = LineDefs[n].sidedef1;
+	if (cur && m >= 0 /* && SideDefs[m].sector >= 0 AYM 1998-06-13 */ )
+	    UnSelectObject(&cur, SideDefs[m].sector);
+	m = LineDefs[n].sidedef2;
+	if (cur && m >= 0 /* && SideDefs[m].sector >= 0 AYM 1998-06-13 */ )
+	    UnSelectObject(&cur, SideDefs[m].sector);
+	continue;
+    }
 /* check if there are any Sectors left */
-if (cur
- && (Expert
-     || Confirm (-1, -1, "Some sectors are not bound to any sidedef",
-			"Do you want to delete these unused sectors?")))
-   DeleteObjects (OBJ_SECTORS, &cur);
-else
-   ForgetSelection (&cur);
+    if (cur
+	&& (Expert
+	    || Confirm(-1, -1, "Some sectors are not bound to any sidedef",
+		       "Do you want to delete these unused sectors?")))
+	DeleteObjects(OBJ_SECTORS, &cur);
+    else
+	ForgetSelection(&cur);
 }
 
 
@@ -578,165 +594,176 @@
    check for missing textures
 */
 
-void CheckTextures () /* SWAP! */
+void CheckTextures()		/* SWAP! */
 {
-int  n;
-int  sd1, sd2;
-int  s1, s2;
-char msg1[80], msg2[80];
-bool first_time = true;
+    int n;
+    int sd1, sd2;
+    int s1, s2;
+    char msg1[80], msg2[80];
+    bool first_time = true;
 
-CheckingObjects ();
-LogMessage ("\nVerifying textures...\n");
-for (n = 0; n < NumSectors; n++)
-   {
-   if (strcmp (Sectors[n].ceilt, "-") == 0
-     || strcmp (Sectors[n].ceilt, "") == 0
-     || memcmp (Sectors[n].ceilt, "        ", 8) == 0)
-      {
-      sprintf (msg1, "Error: sector #%d has no ceiling texture", n);
-      sprintf (msg2, "You probably used a brain-damaged editor to do that...");
-      CheckFailed (-1, -1, msg1, msg2, 1, first_time);
-      GoToObject (Objid (OBJ_SECTORS, n));
-      return;
-      }
-   if (strcmp (Sectors[n].floort, "-") == 0
-     || strcmp (Sectors[n].floort, "") == 0
-     || memcmp (Sectors[n].floort, "        ", 8) == 0)
-      {
-      sprintf (msg1, "Error: sector #%d has no floor texture", n);
-      sprintf (msg2, "You probably used a brain-damaged editor to do that...");
-      CheckFailed (-1, -1, msg1, msg2, 1, first_time);
-      GoToObject (Objid (OBJ_SECTORS, n));
-      return;
-      }
-   if (Sectors[n].ceilh < Sectors[n].floorh)
-      {
-      sprintf (msg1,
-	"Error: sector #%d has its ceiling lower than its floor", n);
-      sprintf (msg2,
-	"The textures will never be displayed if you cannot go there");
-      CheckFailed (-1, -1, msg1, msg2, 1, first_time);
-      GoToObject (Objid (OBJ_SECTORS, n));
-      return;
-      }
-#if 0  /* AYM 2000-08-13 */
-   if (Sectors[n].ceilh - Sectors[n].floorh > 1023)
-      {
-      sprintf (msg1, "Error: sector #%d has its ceiling too high", n);
-      sprintf (msg2, "The maximum difference allowed is 1023 (ceiling - floor)");
-      CheckFailed (-1, -1, msg1, msg2, 1, first_time);
-      GoToObject (Objid (OBJ_SECTORS, n));
-      return;
-      }
+    CheckingObjects();
+    LogMessage("\nVerifying textures...\n");
+    for (n = 0; n < NumSectors; n++)
+    {
+	if (strcmp(Sectors[n].ceilt, "-") == 0
+	    || strcmp(Sectors[n].ceilt, "") == 0
+	    || memcmp(Sectors[n].ceilt, "        ", 8) == 0)
+	{
+	    sprintf(msg1, "Error: sector #%d has no ceiling texture", n);
+	    sprintf(msg2,
+		    "You probably used a brain-damaged editor to do that...");
+	    CheckFailed(-1, -1, msg1, msg2, 1, first_time);
+	    GoToObject(Objid(OBJ_SECTORS, n));
+	    return;
+	}
+	if (strcmp(Sectors[n].floort, "-") == 0
+	    || strcmp(Sectors[n].floort, "") == 0
+	    || memcmp(Sectors[n].floort, "        ", 8) == 0)
+	{
+	    sprintf(msg1, "Error: sector #%d has no floor texture", n);
+	    sprintf(msg2,
+		    "You probably used a brain-damaged editor to do that...");
+	    CheckFailed(-1, -1, msg1, msg2, 1, first_time);
+	    GoToObject(Objid(OBJ_SECTORS, n));
+	    return;
+	}
+	if (Sectors[n].ceilh < Sectors[n].floorh)
+	{
+	    sprintf(msg1,
+		    "Error: sector #%d has its ceiling lower than its floor",
+		    n);
+	    sprintf(msg2,
+		    "The textures will never be displayed if you cannot go there");
+	    CheckFailed(-1, -1, msg1, msg2, 1, first_time);
+	    GoToObject(Objid(OBJ_SECTORS, n));
+	    return;
+	}
+#if 0				/* AYM 2000-08-13 */
+	if (Sectors[n].ceilh - Sectors[n].floorh > 1023)
+	{
+	    sprintf(msg1, "Error: sector #%d has its ceiling too high", n);
+	    sprintf(msg2,
+		    "The maximum difference allowed is 1023 (ceiling - floor)");
+	    CheckFailed(-1, -1, msg1, msg2, 1, first_time);
+	    GoToObject(Objid(OBJ_SECTORS, n));
+	    return;
+	}
 #endif
-   }
+    }
 
-for (n = 0; n < NumLineDefs; n++)
-   {
-   sd1 = LineDefs[n].sidedef1;
-   sd2 = LineDefs[n].sidedef2;
-   if (sd1 >= 0)
-      s1 = SideDefs[sd1].sector;
-   else
-      s1 = OBJ_NO_NONE;
-   if (sd2 >= 0)
-      s2 = SideDefs[sd2].sector;
-   else
-      s2 = OBJ_NO_NONE;
-   if (is_obj (s1) && ! is_obj (s2))
-      {
-      if (SideDefs[sd1].tex3[0] == '-' && SideDefs[sd1].tex3[1] == '\0')
-	 {
-	 sprintf (msg1, "Error in one-sided linedef #%d:"
-	   " sidedef #%d has no middle texture", n, sd1);
-	 sprintf (msg2, "Do you want to set the texture to \"%s\""
-	   " and continue?", default_middle_texture);
-	 if (CheckFailed (-1, -1, msg1, msg2, 0, first_time))
+    for (n = 0; n < NumLineDefs; n++)
+    {
+	sd1 = LineDefs[n].sidedef1;
+	sd2 = LineDefs[n].sidedef2;
+	if (sd1 >= 0)
+	    s1 = SideDefs[sd1].sector;
+	else
+	    s1 = OBJ_NO_NONE;
+	if (sd2 >= 0)
+	    s2 = SideDefs[sd2].sector;
+	else
+	    s2 = OBJ_NO_NONE;
+	if (is_obj(s1) && !is_obj(s2))
+	{
+	    if (SideDefs[sd1].tex3[0] == '-' && SideDefs[sd1].tex3[1] == '\0')
 	    {
-	    GoToObject (Objid (OBJ_LINEDEFS, n));
-	    return;
+		sprintf(msg1, "Error in one-sided linedef #%d:"
+			" sidedef #%d has no middle texture", n, sd1);
+		sprintf(msg2, "Do you want to set the texture to \"%s\""
+			" and continue?", default_middle_texture);
+		if (CheckFailed(-1, -1, msg1, msg2, 0, first_time))
+		{
+		    GoToObject(Objid(OBJ_LINEDEFS, n));
+		    return;
+		}
+		strncpy(SideDefs[sd1].tex3, default_middle_texture,
+			WAD_TEX_NAME);
+		MadeChanges = 1;
+		CheckingObjects();
 	    }
-	 strncpy (SideDefs[sd1].tex3, default_middle_texture, WAD_TEX_NAME);
-         MadeChanges = 1;
-	 CheckingObjects ();
-	 }
-      }
-   if (is_obj (s1) && is_obj (s2) && Sectors[s1].ceilh > Sectors[s2].ceilh)
-      {
-      if (SideDefs[sd1].tex1[0] == '-' && SideDefs[sd1].tex1[1] == '\0'
-	  && (! is_sky (Sectors[s1].ceilt) || ! is_sky (Sectors[s2].ceilt)))
-	 {
-	 sprintf (msg1, "Error in first sidedef of linedef #%d:"
-	   " sidedef #%d has no upper texture", n, sd1);
-	 sprintf (msg2, "Do you want to set the texture to \"%s\""
-	   " and continue?", default_upper_texture);
-	 if (CheckFailed (-1, -1, msg1, msg2, 0, first_time))
+	}
+	if (is_obj(s1) && is_obj(s2) && Sectors[s1].ceilh > Sectors[s2].ceilh)
+	{
+	    if (SideDefs[sd1].tex1[0] == '-' && SideDefs[sd1].tex1[1] == '\0'
+		&& (!is_sky(Sectors[s1].ceilt) || !is_sky(Sectors[s2].ceilt)))
 	    {
-	    GoToObject (Objid (OBJ_LINEDEFS, n));
-	    return;
+		sprintf(msg1, "Error in first sidedef of linedef #%d:"
+			" sidedef #%d has no upper texture", n, sd1);
+		sprintf(msg2, "Do you want to set the texture to \"%s\""
+			" and continue?", default_upper_texture);
+		if (CheckFailed(-1, -1, msg1, msg2, 0, first_time))
+		{
+		    GoToObject(Objid(OBJ_LINEDEFS, n));
+		    return;
+		}
+		strncpy(SideDefs[sd1].tex1, default_upper_texture,
+			WAD_TEX_NAME);
+		MadeChanges = 1;
+		CheckingObjects();
 	    }
-	 strncpy (SideDefs[sd1].tex1, default_upper_texture, WAD_TEX_NAME);
-         MadeChanges = 1;
-	 CheckingObjects ();
-	 }
-      }
-   if (is_obj (s1) && is_obj (s2) && Sectors[s1].floorh < Sectors[s2].floorh)
-      {
-      if (SideDefs[sd1].tex2[0] == '-' && SideDefs[sd1].tex2[1] == '\0')
-	 {
-	 sprintf (msg1, "Error in first sidedef of linedef #%d:"
-	   " sidedef #%d has no lower texture", n, sd1);
-	 sprintf (msg2, "Do you want to set the texture to \"%s\""
-	   " and continue?", default_lower_texture);
-	 if (CheckFailed (-1, -1, msg1, msg2, 0, first_time))
+	}
+	if (is_obj(s1) && is_obj(s2)
+	    && Sectors[s1].floorh < Sectors[s2].floorh)
+	{
+	    if (SideDefs[sd1].tex2[0] == '-' && SideDefs[sd1].tex2[1] == '\0')
 	    {
-	    GoToObject (Objid (OBJ_LINEDEFS, n));
-	    return;
+		sprintf(msg1, "Error in first sidedef of linedef #%d:"
+			" sidedef #%d has no lower texture", n, sd1);
+		sprintf(msg2, "Do you want to set the texture to \"%s\""
+			" and continue?", default_lower_texture);
+		if (CheckFailed(-1, -1, msg1, msg2, 0, first_time))
+		{
+		    GoToObject(Objid(OBJ_LINEDEFS, n));
+		    return;
+		}
+		strncpy(SideDefs[sd1].tex2, default_lower_texture,
+			WAD_TEX_NAME);
+		MadeChanges = 1;
+		CheckingObjects();
 	    }
-	 strncpy (SideDefs[sd1].tex2, default_lower_texture, WAD_TEX_NAME);
-         MadeChanges = 1;
-	 CheckingObjects ();
-	 }
-      }
-   if (is_obj (s1) && is_obj (s2) && Sectors[s2].ceilh > Sectors[s1].ceilh)
-      {
-      if (SideDefs[sd2].tex1[0] == '-' && SideDefs[sd2].tex1[1] == '\0'
-	  && (! is_sky (Sectors[s1].ceilt) || ! is_sky (Sectors[s2].ceilt)))
-	 {
-	 sprintf (msg1, "Error in second sidedef of linedef #%d:"
-	   " sidedef #%d has no upper texture", n, sd2);
-	 sprintf (msg2, "Do you want to set the texture to \"%s\""
-	   " and continue?", default_upper_texture);
-	 if (CheckFailed (-1, -1, msg1, msg2, 0, first_time))
+	}
+	if (is_obj(s1) && is_obj(s2) && Sectors[s2].ceilh > Sectors[s1].ceilh)
+	{
+	    if (SideDefs[sd2].tex1[0] == '-' && SideDefs[sd2].tex1[1] == '\0'
+		&& (!is_sky(Sectors[s1].ceilt) || !is_sky(Sectors[s2].ceilt)))
 	    {
-	    GoToObject (Objid (OBJ_LINEDEFS, n));
-	    return;
+		sprintf(msg1, "Error in second sidedef of linedef #%d:"
+			" sidedef #%d has no upper texture", n, sd2);
+		sprintf(msg2, "Do you want to set the texture to \"%s\""
+			" and continue?", default_upper_texture);
+		if (CheckFailed(-1, -1, msg1, msg2, 0, first_time))
+		{
+		    GoToObject(Objid(OBJ_LINEDEFS, n));
+		    return;
+		}
+		strncpy(SideDefs[sd2].tex1, default_upper_texture,
+			WAD_TEX_NAME);
+		MadeChanges = 1;
+		CheckingObjects();
 	    }
-	 strncpy (SideDefs[sd2].tex1, default_upper_texture, WAD_TEX_NAME);
-         MadeChanges = 1;
-	 CheckingObjects ();
-	 }
-      }
-   if (is_obj (s1) && is_obj (s2) && Sectors[s2].floorh < Sectors[s1].floorh)
-      {
-      if (SideDefs[sd2].tex2[0] == '-' && SideDefs[sd2].tex2[1] == '\0')
-	 {
-	 sprintf (msg1, "Error in second sidedef of linedef #%d:"
-	   " sidedef #%d has no lower texture", n, sd2);
-	 sprintf (msg2, "Do you want to set the texture to \"%s\""
-	   " and continue?", default_lower_texture);
-	 if (CheckFailed (-1, -1, msg1, msg2, 0, first_time))
+	}
+	if (is_obj(s1) && is_obj(s2)
+	    && Sectors[s2].floorh < Sectors[s1].floorh)
+	{
+	    if (SideDefs[sd2].tex2[0] == '-' && SideDefs[sd2].tex2[1] == '\0')
 	    {
-	    GoToObject (Objid (OBJ_LINEDEFS, n));
-	    return;
+		sprintf(msg1, "Error in second sidedef of linedef #%d:"
+			" sidedef #%d has no lower texture", n, sd2);
+		sprintf(msg2, "Do you want to set the texture to \"%s\""
+			" and continue?", default_lower_texture);
+		if (CheckFailed(-1, -1, msg1, msg2, 0, first_time))
+		{
+		    GoToObject(Objid(OBJ_LINEDEFS, n));
+		    return;
+		}
+		strncpy(SideDefs[sd2].tex2, default_lower_texture,
+			WAD_TEX_NAME);
+		MadeChanges = 1;
+		CheckingObjects();
 	    }
-	 strncpy (SideDefs[sd2].tex2, default_lower_texture, WAD_TEX_NAME);
-         MadeChanges = 1;
-	 CheckingObjects ();
-	 }
-      }
-   }
+	}
+    }
 }
 
 
@@ -744,14 +771,14 @@
    check if a texture name matches one of the elements of a list
 */
 
-bool IsTextureNameInList (char *name, char **list, int numelems)
+bool IsTextureNameInList(char *name, char **list, int numelems)
 {
-int n;
+    int n;
 
-for (n = 0; n < numelems; n++)
-   if (! y_strnicmp (name, list[n], WAD_TEX_NAME))
-      return true;
-return false;
+    for (n = 0; n < numelems; n++)
+	if (!y_strnicmp(name, list[n], WAD_TEX_NAME))
+	    return true;
+    return false;
 }
 
 
@@ -759,85 +786,85 @@
    check for invalid texture names
 */
 
-void CheckTextureNames () /* SWAP! */
+void CheckTextureNames()	/* SWAP! */
 {
-int  n;
-char msg1[80], msg2[80];
-bool first_time = true;
+    int n;
+    char msg1[80], msg2[80];
+    bool first_time = true;
 
-CheckingObjects ();
-LogMessage ("\nVerifying texture names...\n");
+    CheckingObjects();
+    LogMessage("\nVerifying texture names...\n");
 
 // AYM 2000-07-24: could someone explain this one ?
-if (! FindMasterDir (MasterDir, "F2_START"))
-   NumThings--;
+    if (!FindMasterDir(MasterDir, "F2_START"))
+	NumThings--;
 
-for (n = 0; n < NumSectors; n++)
-   {
-   if (! is_flat_name_in_list (Sectors[n].ceilt))
-      {
-      sprintf (msg1, "Invalid ceiling texture in sector #%d", n);
-      sprintf (msg2, "The name \"%.*s\" is not a floor/ceiling texture",
-	(int) WAD_FLAT_NAME, Sectors[n].ceilt);
-      if (CheckFailed (-1, -1, msg1, msg2, 0, first_time))
-	 {
-	 GoToObject (Objid (OBJ_SECTORS, n));
-	 return;
-	 }
-      CheckingObjects ();
-      }
-   if (! is_flat_name_in_list (Sectors[n].floort))
-      {
-      sprintf (msg1, "Invalid floor texture in sector #%d", n);
-      sprintf (msg2, "The name \"%.*s\" is not a floor/ceiling texture",
-	(int) WAD_FLAT_NAME, Sectors[n].floort);
-      if (CheckFailed (-1, -1, msg1, msg2, 0, first_time))
-	 {
-	 GoToObject (Objid (OBJ_SECTORS, n));
-	 return;
-	 }
-      CheckingObjects ();
-      }
-   }
-for (n = 0; n < NumSideDefs; n++)
-   {
-   if (! IsTextureNameInList (SideDefs[n].tex1, WTexture, NumWTexture))
-      {
-      sprintf (msg1, "Invalid upper texture in sidedef #%d", n);
-      sprintf (msg2, "The name \"%.*s\" is not a wall texture",
-	(int) WAD_TEX_NAME, SideDefs[n].tex1);
-      if (CheckFailed (-1, -1, msg1, msg2, 0, first_time))
-	 {
-	 GoToObject (Objid (OBJ_SIDEDEFS, n));
-	 return;
-	 }
-      CheckingObjects ();
-      }
-   if (! IsTextureNameInList (SideDefs[n].tex2, WTexture, NumWTexture))
-      {
-      sprintf (msg1, "Invalid lower texture in sidedef #%d", n);
-      sprintf (msg2, "The name \"%.*s\" is not a wall texture",
-	(int) WAD_TEX_NAME, SideDefs[n].tex2);
-      if (CheckFailed (-1, -1, msg1, msg2, 0, first_time))
-	 {
-	 GoToObject (Objid (OBJ_SIDEDEFS, n));
-	 return;
-	 }
-      CheckingObjects ();
-      }
-   if (! IsTextureNameInList (SideDefs[n].tex3, WTexture, NumWTexture))
-      {
-      sprintf (msg1, "Invalid middle texture in sidedef #%d", n);
-      sprintf (msg2, "The name \"%.*s\" is not a wall texture",
-	(int) WAD_TEX_NAME, SideDefs[n].tex3);
-      if (CheckFailed (-1, -1, msg1, msg2, 0, first_time))
-	 {
-	 GoToObject (Objid (OBJ_SIDEDEFS, n));
-	 return;
-	 }
-      CheckingObjects ();
-      }
-   }
+    for (n = 0; n < NumSectors; n++)
+    {
+	if (!is_flat_name_in_list(Sectors[n].ceilt))
+	{
+	    sprintf(msg1, "Invalid ceiling texture in sector #%d", n);
+	    sprintf(msg2, "The name \"%.*s\" is not a floor/ceiling texture",
+		    (int) WAD_FLAT_NAME, Sectors[n].ceilt);
+	    if (CheckFailed(-1, -1, msg1, msg2, 0, first_time))
+	    {
+		GoToObject(Objid(OBJ_SECTORS, n));
+		return;
+	    }
+	    CheckingObjects();
+	}
+	if (!is_flat_name_in_list(Sectors[n].floort))
+	{
+	    sprintf(msg1, "Invalid floor texture in sector #%d", n);
+	    sprintf(msg2, "The name \"%.*s\" is not a floor/ceiling texture",
+		    (int) WAD_FLAT_NAME, Sectors[n].floort);
+	    if (CheckFailed(-1, -1, msg1, msg2, 0, first_time))
+	    {
+		GoToObject(Objid(OBJ_SECTORS, n));
+		return;
+	    }
+	    CheckingObjects();
+	}
+    }
+    for (n = 0; n < NumSideDefs; n++)
+    {
+	if (!IsTextureNameInList(SideDefs[n].tex1, WTexture, NumWTexture))
+	{
+	    sprintf(msg1, "Invalid upper texture in sidedef #%d", n);
+	    sprintf(msg2, "The name \"%.*s\" is not a wall texture",
+		    (int) WAD_TEX_NAME, SideDefs[n].tex1);
+	    if (CheckFailed(-1, -1, msg1, msg2, 0, first_time))
+	    {
+		GoToObject(Objid(OBJ_SIDEDEFS, n));
+		return;
+	    }
+	    CheckingObjects();
+	}
+	if (!IsTextureNameInList(SideDefs[n].tex2, WTexture, NumWTexture))
+	{
+	    sprintf(msg1, "Invalid lower texture in sidedef #%d", n);
+	    sprintf(msg2, "The name \"%.*s\" is not a wall texture",
+		    (int) WAD_TEX_NAME, SideDefs[n].tex2);
+	    if (CheckFailed(-1, -1, msg1, msg2, 0, first_time))
+	    {
+		GoToObject(Objid(OBJ_SIDEDEFS, n));
+		return;
+	    }
+	    CheckingObjects();
+	}
+	if (!IsTextureNameInList(SideDefs[n].tex3, WTexture, NumWTexture))
+	{
+	    sprintf(msg1, "Invalid middle texture in sidedef #%d", n);
+	    sprintf(msg2, "The name \"%.*s\" is not a wall texture",
+		    (int) WAD_TEX_NAME, SideDefs[n].tex3);
+	    if (CheckFailed(-1, -1, msg1, msg2, 0, first_time))
+	    {
+		GoToObject(Objid(OBJ_SIDEDEFS, n));
+		return;
+	    }
+	    CheckingObjects();
+	}
+    }
 }
 
 
@@ -845,74 +872,74 @@
    check for players starting points
 */
 
-bool CheckStartingPos () /* SWAP! */
+bool CheckStartingPos()		/* SWAP! */
 {
-char msg1[80], msg2[80];
-bool p1 = false;
-bool p2 = false;
-bool p3 = false;
-bool p4 = false;
-size_t dm = 0;
-int  t;
+    char msg1[80], msg2[80];
+    bool p1 = false;
+    bool p2 = false;
+    bool p3 = false;
+    bool p4 = false;
+    size_t dm = 0;
+    int t;
 
-for (t = 0; t < NumThings; t++)
-   {
-   if (Things[t].type == THING_PLAYER1)
-      p1 = true;
-   if (Things[t].type == THING_PLAYER2)
-      p2 = true;
-   if (Things[t].type == THING_PLAYER3)
-      p3 = true;
-   if (Things[t].type == THING_PLAYER4)
-      p4 = true;
-   if (Things[t].type == THING_DEATHMATCH)
-      dm++;
-   }
-if (! p1)
-   {
-   Beep ();
-   if (! Confirm (-1, -1, "Warning: there is no player 1 starting point. The"
-       " game", "will crash if you play with this level. Save anyway ?"))
-      return false;
-   else 
-      return true;  // No point in doing further checking !
-   }
-if (Expert)
-   return true;
-if (! p2 || ! p3 || ! p4)
-   {
-   if (! p4)
-     t = 4;
-   if (! p3)
-     t = 3;
-   if (! p2)
-     t = 2;
-   sprintf (msg1, "Warning: there is no player %d start."
-     " You will not be able", t);
-   sprintf (msg2, "to use this level for multi-player games."
-     " Save anyway ?");
-   if (! Confirm (-1, -1, msg1, msg2))
-      return false;
-   else
-      return true;  // No point in doing further checking !
-   }
-if (dm < DOOM_MIN_DEATHMATCH_STARTS)
-   {
-   if (dm == 0)
-     sprintf (msg1, "Warning: there are no deathmatch starts."
-       " You need at least %d", DOOM_MIN_DEATHMATCH_STARTS);
-   else if (dm == 1)
-     sprintf (msg1, "Warning: there is only one deathmatch start."
-       " You need at least %d", DOOM_MIN_DEATHMATCH_STARTS);
-   else
-     sprintf (msg1, "Warning: there are only %d deathmatch starts."
-       " You need at least %d", dm, DOOM_MIN_DEATHMATCH_STARTS);
-   sprintf (msg2, "deathmatch starts to play deathmatch games."
-     " Save anyway ?");
-   if (! Confirm (-1, -1, msg1, msg2))
-     return false;
-   }
-return true;
+    for (t = 0; t < NumThings; t++)
+    {
+	if (Things[t].type == THING_PLAYER1)
+	    p1 = true;
+	if (Things[t].type == THING_PLAYER2)
+	    p2 = true;
+	if (Things[t].type == THING_PLAYER3)
+	    p3 = true;
+	if (Things[t].type == THING_PLAYER4)
+	    p4 = true;
+	if (Things[t].type == THING_DEATHMATCH)
+	    dm++;
+    }
+    if (!p1)
+    {
+	Beep();
+	if (!Confirm
+	    (-1, -1,
+	     "Warning: there is no player 1 starting point. The" " game",
+	     "will crash if you play with this level. Save anyway ?"))
+	    return false;
+	else
+	    return true;	// No point in doing further checking !
+    }
+    if (Expert)
+	return true;
+    if (!p2 || !p3 || !p4)
+    {
+	if (!p4)
+	    t = 4;
+	if (!p3)
+	    t = 3;
+	if (!p2)
+	    t = 2;
+	sprintf(msg1, "Warning: there is no player %d start."
+		" You will not be able", t);
+	sprintf(msg2, "to use this level for multi-player games."
+		" Save anyway ?");
+	if (!Confirm(-1, -1, msg1, msg2))
+	    return false;
+	else
+	    return true;	// No point in doing further checking !
+    }
+    if (dm < DOOM_MIN_DEATHMATCH_STARTS)
+    {
+	if (dm == 0)
+	    sprintf(msg1, "Warning: there are no deathmatch starts."
+		    " You need at least %d", DOOM_MIN_DEATHMATCH_STARTS);
+	else if (dm == 1)
+	    sprintf(msg1, "Warning: there is only one deathmatch start."
+		    " You need at least %d", DOOM_MIN_DEATHMATCH_STARTS);
+	else
+	    sprintf(msg1, "Warning: there are only %d deathmatch starts."
+		    " You need at least %d", dm, DOOM_MIN_DEATHMATCH_STARTS);
+	sprintf(msg2, "deathmatch starts to play deathmatch games."
+		" Save anyway ?");
+	if (!Confirm(-1, -1, msg1, msg2))
+	    return false;
+    }
+    return true;
 }
-
-
--- a/src/checks.h	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/checks.h	Sat Sep 24 14:16:04 2011 +0300
@@ -4,11 +4,9 @@
  */
 
 
-void CheckLevel (int x0, int y0);
-void Statistics ();
-void CheckSectors ();
-void CheckCrossReferences ();
-void CheckTextures ();
-void CheckTextureNames ();
-
-
+void CheckLevel(int x0, int y0);
+void Statistics();
+void CheckSectors();
+void CheckCrossReferences();
+void CheckTextures();
+void CheckTextureNames();
--- a/src/colour.h	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/colour.h	Sat Sep 24 14:16:04 2011 +0300
@@ -4,8 +4,8 @@
  */
 
 
-#ifndef YH_COLOUR  // Prevent multiple inclusion
-#define YH_COLOUR  // Prevent multiple inclusion
+#ifndef YH_COLOUR		// Prevent multiple inclusion
+#define YH_COLOUR		// Prevent multiple inclusion
 
 class rgb_c;
 
@@ -20,9 +20,9 @@
 typedef unsigned long pcolour_t;	// X11: up to 32 BPP.
 #define PCOLOUR_NONE  0xffffffff	/* An "impossible" colour no. */
 
-pcolour_t *alloc_colours (rgb_c rgb_values[], size_t count);
-void free_colours (pcolour_t *pc, size_t count);
-size_t get_pcolours_count ();
-pcolour_t get_pcolour_pcn (size_t i);
+pcolour_t *alloc_colours(rgb_c rgb_values[], size_t count);
+void free_colours(pcolour_t * pc, size_t count);
+size_t get_pcolours_count();
+pcolour_t get_pcolour_pcn(size_t i);
 
-#endif	// Prevent multiple inclusions
+#endif // Prevent multiple inclusions
--- a/src/colour1.cc	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/colour1.cc	Sat Sep 24 14:16:04 2011 +0300
@@ -32,7 +32,7 @@
 #include "rgb.h"
 
 
-#define RGB_DIGITS 2  /* R, G and B are 8-bit wide each */
+#define RGB_DIGITS 2		/* R, G and B are 8-bit wide each */
 
 
 /*
@@ -42,54 +42,53 @@
  *	  0    OK
  *	  <>0  malformed colour specification
  */
-int getcolour (const char *s, rgb_c *rgb)
+int getcolour(const char *s, rgb_c * rgb)
 {
-  int i;
-  int digit;
-  int rdigits;
-  int gdigits;
-  int bdigits;
-  unsigned r;
-  unsigned g;
-  unsigned b;
-  int globaldigits;
+    int i;
+    int digit;
+    int rdigits;
+    int gdigits;
+    int bdigits;
+    unsigned r;
+    unsigned g;
+    unsigned b;
+    int globaldigits;
 
-  if (strncmp (s, "rgb:", 4))
-    return 1;
+    if (strncmp(s, "rgb:", 4))
+	return 1;
 
-  for (i = 4, r = 0, rdigits = 0; (digit = hextoi (s[i])) >= 0; i++, rdigits++)
-    r = (r << 4) | digit;
-  if (s[i++] != '/')
-    return 2;
+    for (i = 4, r = 0, rdigits = 0; (digit = hextoi(s[i])) >= 0;
+	 i++, rdigits++)
+	r = (r << 4) | digit;
+    if (s[i++] != '/')
+	return 2;
 
-  for (g = 0, gdigits = 0; (digit = hextoi (s[i])) >= 0; i++, gdigits++)
-    g = (g << 4) | digit;
-  if (s[i++] != '/')
-    return 3;
-    
-  for (b = 0, bdigits = 0; (digit = hextoi (s[i])) >= 0; i++, bdigits++)
-    b = (b << 4) | digit;
-  if (s[i++] != '\0')
-    return 4;
+    for (g = 0, gdigits = 0; (digit = hextoi(s[i])) >= 0; i++, gdigits++)
+	g = (g << 4) | digit;
+    if (s[i++] != '/')
+	return 3;
+
+    for (b = 0, bdigits = 0; (digit = hextoi(s[i])) >= 0; i++, bdigits++)
+	b = (b << 4) | digit;
+    if (s[i++] != '\0')
+	return 4;
 
-  // Force to 8 bits (RGB_DIGITS hex digits) by scaling up or down
-  globaldigits = rdigits;
-  globaldigits = y_max (globaldigits, gdigits);
-  globaldigits = y_max (globaldigits, bdigits);
-  for (; globaldigits < RGB_DIGITS; globaldigits++)
-  {
-    r <<= 4;
-    g <<= 4;
-    b <<= 4;
-  }
-  for (; globaldigits > RGB_DIGITS; globaldigits--)
-  {
-    r >>= 4;
-    g >>= 4;
-    b >>= 4;
-  }
-  rgb->set (r, g, b);
-  return 0;
+    // Force to 8 bits (RGB_DIGITS hex digits) by scaling up or down
+    globaldigits = rdigits;
+    globaldigits = y_max(globaldigits, gdigits);
+    globaldigits = y_max(globaldigits, bdigits);
+    for (; globaldigits < RGB_DIGITS; globaldigits++)
+    {
+	r <<= 4;
+	g <<= 4;
+	b <<= 4;
+    }
+    for (; globaldigits > RGB_DIGITS; globaldigits--)
+    {
+	r >>= 4;
+	g >>= 4;
+	b >>= 4;
+    }
+    rgb->set(r, g, b);
+    return 0;
 }
-
-
--- a/src/colour2.cc	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/colour2.cc	Sat Sep 24 14:16:04 2011 +0300
@@ -35,13 +35,12 @@
  *	rgb2irgb
  *	Convert an RGB colour to an IRGB (16-colour VGA) colour.
  */
-int rgb2irgb (int r, int g, int b)
+int rgb2irgb(int r, int g, int b)
 {
-  int c;
+    int c;
 
-  c = 4*!!r + 2*!!g + 1*!!b;
-  if (r > 128 || g > 128 || b > 128)
-    c += 8;  // Set high intensity bit
-  return c;
+    c = 4 * ! !r + 2 * ! !g + 1 * ! !b;
+    if (r > 128 || g > 128 || b > 128)
+	c += 8;			// Set high intensity bit
+    return c;
 }
-
--- a/src/colour3.cc	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/colour3.cc	Sat Sep 24 14:16:04 2011 +0300
@@ -37,15 +37,14 @@
  *	Convert an IRGB colour (16-colour VGA) to an 8-bit-per-component
  *	RGB colour.
  */
-void irgb2rgb (int c, rgb_c *rgb)
+void irgb2rgb(int c, rgb_c * rgb)
 {
-  if (c == 8)  // Special case for DARKGREY
-    rgb->r = rgb->g = rgb->b = 0x40;
-  else
-  {
-    rgb->r = (c & 4) ? ((c & 8) ? 0xff : 0x80) : 0;
-    rgb->g = (c & 2) ? ((c & 8) ? 0xff : 0x80) : 0;
-    rgb->b = (c & 1) ? ((c & 8) ? 0xff : 0x80) : 0;
-  }
+    if (c == 8)			// Special case for DARKGREY
+	rgb->r = rgb->g = rgb->b = 0x40;
+    else
+    {
+	rgb->r = (c & 4) ? ((c & 8) ? 0xff : 0x80) : 0;
+	rgb->g = (c & 2) ? ((c & 8) ? 0xff : 0x80) : 0;
+	rgb->b = (c & 1) ? ((c & 8) ? 0xff : 0x80) : 0;
+    }
 }
-
--- a/src/colour4.cc	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/colour4.cc	Sat Sep 24 14:16:04 2011 +0300
@@ -40,17 +40,17 @@
 
 /* This table contains all the physical colours allocated,
    with their rgb value and usage count. */
-typedef struct 
+typedef struct
 {
-  pcolour_t pcn;	// The physical colour# (pixel value).
-  rgb_c rgb;		// Its RGB value.
-  int usage_count;	// Number of logical colours that use it.
+    pcolour_t pcn;		// The physical colour# (pixel value).
+    rgb_c rgb;			// Its RGB value.
+    int usage_count;		// Number of logical colours that use it.
 } pcolours_table_entry_t;
 pcolours_table_entry_t *pcolours = 0;
-size_t physical_colours = 0;  // Number of entries in <pcolours>
+size_t physical_colours = 0;	// Number of entries in <pcolours>
 
 
-static void dump_pcolours ();
+static void dump_pcolours();
 
 
 /*
@@ -58,9 +58,9 @@
  *	Convert an 8-bit RGB component value to a 16-bit one.
  *	Will convert 00h to 0000h, 80h to 8080h and FFh to FFFFh.
  */
-inline u16 eight2sixteen (u8 v)
+inline u16 eight2sixteen(u8 v)
 {
-  return (v << 8) | v;
+    return (v << 8) | v;
 }
 
 
@@ -69,83 +69,83 @@
  *	Allocate a group of <count> rgb values and return an array of
  *	<count> physical colour numbers.
  */
-pcolour_t *alloc_colours (rgb_c rgb_values[], size_t count)
+pcolour_t *alloc_colours(rgb_c rgb_values[], size_t count)
 {
-  verbmsg ("colours: alloc_colours: count %d\n", count);
-
-  pcolour_t *pcn_table = (pcolour_t *) malloc (count * sizeof *pcn_table);
-  if (pcn_table == NULL)
-    fatal_error (msg_nomem);
+    verbmsg("colours: alloc_colours: count %d\n", count);
 
-  /* Allocate the physical colours if necessary. Should not do
-     it for static visuals (StaticColor, TrueColor). It does no
-     harm but it's useless. */
-  for (size_t n = 0; n < count; n++)
-  {
-    // Is there already a physical colour for this RGB value ?
-    pcn_table[n] = PCOLOUR_NONE;
-    for (size_t i = 0; i < physical_colours; i++)
+    pcolour_t *pcn_table = (pcolour_t *) malloc(count * sizeof *pcn_table);
+    if (pcn_table == NULL)
+	fatal_error(msg_nomem);
+
+    /* Allocate the physical colours if necessary. Should not do
+       it for static visuals (StaticColor, TrueColor). It does no
+       harm but it's useless. */
+    for (size_t n = 0; n < count; n++)
     {
-      if (pcolours[i].rgb == rgb_values[n])
-      {
-	// There is. Reuse it.
-	pcn_table[n] = pcolours[i].pcn;
-	pcolours[i].usage_count++;
-	break;
-      }
-    }
+	// Is there already a physical colour for this RGB value ?
+	pcn_table[n] = PCOLOUR_NONE;
+	for (size_t i = 0; i < physical_colours; i++)
+	{
+	    if (pcolours[i].rgb == rgb_values[n])
+	    {
+		// There is. Reuse it.
+		pcn_table[n] = pcolours[i].pcn;
+		pcolours[i].usage_count++;
+		break;
+	    }
+	}
 
-    // There isn't. Try to create a new physical colour.
-    if (pcn_table[n] == PCOLOUR_NONE)
-    {
-      XColor xc;
-      xc.red   = eight2sixteen (rgb_values[n].r);
-      xc.green = eight2sixteen (rgb_values[n].g);
-      xc.blue  = eight2sixteen (rgb_values[n].b);
-      Status r = XAllocColor (dpy, cmap, &xc);
+	// There isn't. Try to create a new physical colour.
+	if (pcn_table[n] == PCOLOUR_NONE)
+	{
+	    XColor xc;
+	    xc.red = eight2sixteen(rgb_values[n].r);
+	    xc.green = eight2sixteen(rgb_values[n].g);
+	    xc.blue = eight2sixteen(rgb_values[n].b);
+	    Status r = XAllocColor(dpy, cmap, &xc);
 
-      /* Allocation successful. Add a new entry to
-	 the table of physical colours. */
-      if (r != 0)
-      {
-	pcn_table[n] = (pcolour_t) xc.pixel;
-	physical_colours++;
-	pcolours = (pcolours_table_entry_t *)
-	  realloc (pcolours, physical_colours * sizeof *pcolours);
-	if (pcolours == NULL)
-	  fatal_error (msg_nomem);
-	pcolours[physical_colours - 1].pcn         = (pcolour_t) xc.pixel;
-	pcolours[physical_colours - 1].rgb         = rgb_values[n];
-	pcolours[physical_colours - 1].usage_count = 1;
-      }
+	    /* Allocation successful. Add a new entry to
+	       the table of physical colours. */
+	    if (r != 0)
+	    {
+		pcn_table[n] = (pcolour_t) xc.pixel;
+		physical_colours++;
+		pcolours = (pcolours_table_entry_t *)
+		    realloc(pcolours, physical_colours * sizeof *pcolours);
+		if (pcolours == NULL)
+		    fatal_error(msg_nomem);
+		pcolours[physical_colours - 1].pcn = (pcolour_t) xc.pixel;
+		pcolours[physical_colours - 1].rgb = rgb_values[n];
+		pcolours[physical_colours - 1].usage_count = 1;
+	    }
 
-      /* Couldn't allocate (the colormap is full).
-	 Reuse the nearest existing physical colour. */
-      else
-      {
-	size_t best_fit = 0;
-	int best_delta = INT_MAX;
-	
-	for (size_t m = 0; m < physical_colours; m++)
-	{
-	  int delta = pcolours[m].rgb - rgb_values[n];
-	  if (delta < best_delta)
-	  {
-	    best_fit = m;
-	    best_delta = delta;
-	  }
+	    /* Couldn't allocate (the colormap is full).
+	       Reuse the nearest existing physical colour. */
+	    else
+	    {
+		size_t best_fit = 0;
+		int best_delta = INT_MAX;
+
+		for (size_t m = 0; m < physical_colours; m++)
+		{
+		    int delta = pcolours[m].rgb - rgb_values[n];
+		    if (delta < best_delta)
+		    {
+			best_fit = m;
+			best_delta = delta;
+		    }
+		}
+		verbmsg
+		    ("colours: alloc_colours %d/%d/%d: reused %d/%d/%d, delta=%d\n",
+		     rgb_values[n].r, rgb_values[n].g, rgb_values[n].b,
+		     pcolours[best_fit].rgb.r, pcolours[best_fit].rgb.g,
+		     pcolours[best_fit].rgb.b, best_delta);
+		pcn_table[n] = pcolours[best_fit].pcn;
+		pcolours[best_fit].usage_count++;
+	    }
 	}
-	verbmsg ("colours: alloc_colours %d/%d/%d: reused %d/%d/%d, delta=%d\n",
-	   rgb_values[n].r, rgb_values[n].g, rgb_values[n].b, 
-	   pcolours[best_fit].rgb.r, pcolours[best_fit].rgb.g,
-	   pcolours[best_fit].rgb.b,
-	   best_delta);
-	pcn_table[n] = pcolours[best_fit].pcn;
-	pcolours[best_fit].usage_count++;
-      }
     }
-  }
-  return pcn_table;
+    return pcn_table;
 }
 
 
@@ -153,84 +153,84 @@
  *	free_colours
  *	Free the <count> physical colours in <pc>.
  */
-void free_colours (pcolour_t *pcn_table, size_t count)
+void free_colours(pcolour_t * pcn_table, size_t count)
 {
-  verbmsg ("colours: free_colours: count %d\n", count);
-  if (verbose)
-    dump_pcolours ();
+    verbmsg("colours: free_colours: count %d\n", count);
+    if (verbose)
+	dump_pcolours();
+
+    if (pcn_table == NULL)	// Sanity
+	return;
 
-  if (pcn_table == NULL)  // Sanity
-    return;
+    /* Decrement the usage count for all those physical colours.
+       If the usage count reaches 0, actually free them. */
+    for (pcolour_t * pcn = pcn_table; count; count--, pcn++)
+    {
+	size_t i;
 
-  /* Decrement the usage count for all those physical colours.
-     If the usage count reaches 0, actually free them. */
-  for (pcolour_t *pcn = pcn_table; count; count--, pcn++)
-  {
-    size_t i;
+	for (i = 0; i < physical_colours; i++)
+	    if (pcolours[i].pcn == *pcn)
+		break;
 
-    for (i = 0; i < physical_colours; i++)
-      if (pcolours[i].pcn == *pcn)
-	break;
-    
-    if (i == physical_colours)
-      fatal_error ("Trying to free pc[%d]=%ld that does not exist",
-	(int) i, (long) *pcn);
+	if (i == physical_colours)
+	    fatal_error("Trying to free pc[%d]=%ld that does not exist",
+			(int) i, (long) *pcn);
 
-    if (pcolours[i].usage_count < 1)
-      fatal_error ("Freeing unused colour %ld", (long) *pcn);
+	if (pcolours[i].usage_count < 1)
+	    fatal_error("Freeing unused colour %ld", (long) *pcn);
 
-    pcolours[i].usage_count--;
-    if (pcolours[i].usage_count == 0)
-    {
-      unsigned long pixel = (unsigned long) *pcn;
-      x_catch_on ();
-      XFreeColors (dpy, cmap, &pixel, 1, 0);
-      // Should not happen but sometimes does (not reproducible)
-      if (const char *err_msg = x_error ())
-	warn ("error freeing colour %08lXh (%s).\n", pixel, err_msg);
-      x_catch_off ();
-      pcolours[i].pcn = PCOLOUR_NONE;
+	pcolours[i].usage_count--;
+	if (pcolours[i].usage_count == 0)
+	{
+	    unsigned long pixel = (unsigned long) *pcn;
+	    x_catch_on();
+	    XFreeColors(dpy, cmap, &pixel, 1, 0);
+	    // Should not happen but sometimes does (not reproducible)
+	    if (const char *err_msg = x_error())
+		warn("error freeing colour %08lXh (%s).\n", pixel, err_msg);
+	    x_catch_off();
+	    pcolours[i].pcn = PCOLOUR_NONE;
+	}
     }
-  }
 
-  /* If physical colours have actually been freed,
-     remove them from the table of physical colours. */
-  size_t new_physical_colours = 0;
+    /* If physical colours have actually been freed,
+       remove them from the table of physical colours. */
+    size_t new_physical_colours = 0;
 
-  {
-    for (size_t i = 0; i < physical_colours; i++)
-      if (pcolours[i].pcn != PCOLOUR_NONE)
-	new_physical_colours++;  // Number of physical colours still in use.
-  }
+    {
+	for (size_t i = 0; i < physical_colours; i++)
+	    if (pcolours[i].pcn != PCOLOUR_NONE)
+		new_physical_colours++;	// Number of physical colours still in use.
+    }
 
-  verbmsg ("colours: freed %d of %d physical colours\n",
-    physical_colours - new_physical_colours, physical_colours);
+    verbmsg("colours: freed %d of %d physical colours\n",
+	    physical_colours - new_physical_colours, physical_colours);
 
-  if (new_physical_colours == 0)
-  {
-    free (pcolours);
-    pcolours = 0;
-  }
-  else
-  {
-    pcolours_table_entry_t *new_item;
-    pcolours_table_entry_t *new_pcolours = (pcolours_table_entry_t *)
-      malloc (new_physical_colours * sizeof *new_pcolours);
-    if (new_pcolours == NULL)
-      fatal_error (msg_nomem);
-    new_item = new_pcolours;
-    for (size_t i = 0; i < physical_colours; i++)
-      if (pcolours[i].pcn != PCOLOUR_NONE)
-	memcpy (new_item++, pcolours + i, sizeof *new_pcolours);
-    free (pcolours);
-    pcolours = new_pcolours;
-  }
-  physical_colours = new_physical_colours;
+    if (new_physical_colours == 0)
+    {
+	free(pcolours);
+	pcolours = 0;
+    }
+    else
+    {
+	pcolours_table_entry_t *new_item;
+	pcolours_table_entry_t *new_pcolours = (pcolours_table_entry_t *)
+	    malloc(new_physical_colours * sizeof *new_pcolours);
+	if (new_pcolours == NULL)
+	    fatal_error(msg_nomem);
+	new_item = new_pcolours;
+	for (size_t i = 0; i < physical_colours; i++)
+	    if (pcolours[i].pcn != PCOLOUR_NONE)
+		memcpy(new_item++, pcolours + i, sizeof *new_pcolours);
+	free(pcolours);
+	pcolours = new_pcolours;
+    }
+    physical_colours = new_physical_colours;
 
-  //if (verbose)
-  //   dump_pcolours ();
+    //if (verbose)
+    //   dump_pcolours ();
 
-  free (pcn_table);
+    free(pcn_table);
 }
 
 
@@ -238,9 +238,9 @@
  *	get_pcolours_count
  *	Return the number of physical colours allocated
  */
-size_t get_pcolours_count ()
+size_t get_pcolours_count()
 {
-  return physical_colours;
+    return physical_colours;
 }
 
 
@@ -249,14 +249,14 @@
  *	Return the physical colour number (a.k.a. pixel value)
  *	for the <i>th physical colour allocated.
  */
-pcolour_t get_pcolour_pcn (size_t i)
+pcolour_t get_pcolour_pcn(size_t i)
 {
-  if (i >= physical_colours)
-  {
-    nf_bug ("get_pcolour_pcn: i=%d\n", (int) i);
-    return ULONG_MAX;
-  }
-  return pcolours[i].pcn;
+    if (i >= physical_colours)
+    {
+	nf_bug("get_pcolour_pcn: i=%d\n", (int) i);
+	return ULONG_MAX;
+    }
+    return pcolours[i].pcn;
 }
 
 
@@ -264,38 +264,35 @@
  *	dump_pcolours
  *	For debugging purposes
  */
-static void dump_pcolours ()
+static void dump_pcolours()
 {
-  int items_on_current_line = 0;
+    int items_on_current_line = 0;
 
-  for (size_t i = 0; i < physical_colours; i++)
-  {
+    for (size_t i = 0; i < physical_colours; i++)
+    {
 #if 0
-    printf ("%02lX %02X/%02X/%02X %d",
-       pcolours[i].pcn,
-       pcolours[i].rgb.r,
-       pcolours[i].rgb.g,
-       pcolours[i].rgb.b,
-       pcolours[i].usage_count);
-    fputs (i % 5 == 4 ? "\n" : "  ", stdout);
+	printf("%02lX %02X/%02X/%02X %d",
+	       pcolours[i].pcn,
+	       pcolours[i].rgb.r,
+	       pcolours[i].rgb.g, pcolours[i].rgb.b, pcolours[i].usage_count);
+	fputs(i % 5 == 4 ? "\n" : "  ", stdout);
 #endif
-    if (items_on_current_line == 0)
-      verbmsg ("colours: ");
-    verbmsg ("%c",
-	(pcolours[i].usage_count == 1) ? '.' : '0' + pcolours[i].usage_count);
-    if (++items_on_current_line % 10 == 0)
-    {
-      if (items_on_current_line == 50)
-      {
-	items_on_current_line = 0;
-	verbmsg ("\n");
-      }
-      else
-        verbmsg (" ");
+	if (items_on_current_line == 0)
+	    verbmsg("colours: ");
+	verbmsg("%c",
+		(pcolours[i].usage_count ==
+		 1) ? '.' : '0' + pcolours[i].usage_count);
+	if (++items_on_current_line % 10 == 0)
+	{
+	    if (items_on_current_line == 50)
+	    {
+		items_on_current_line = 0;
+		verbmsg("\n");
+	    }
+	    else
+		verbmsg(" ");
+	}
     }
-  }
-  if (items_on_current_line != 0)
-    verbmsg ("\n");
+    if (items_on_current_line != 0)
+	verbmsg("\n");
 }
-
-
--- a/src/credits.cc	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/credits.cc	Sat Sep 24 14:16:04 2011 +0300
@@ -1,12 +1,10 @@
 // DO NOT EDIT -- generated from docsrc/copyright
 
-extern const char *const yadex_copyright[] =
-{
-  "Parts copyright Andrew Apted 2000-2001, GNU GPL v2",
-  "Parts copyright André Majorel 1997-2003, GNU GPL v2",
-  "Parts copyright Matthew W. Miller 2000, GNU GPL v2",
-  "Parts written by Raphaël Quinet, public domain",
-  "Parts written by Brendon Wyber, public domain",
-  0
+extern const char *const yadex_copyright[] = {
+    "Parts copyright Andrew Apted 2000-2001, GNU GPL v2",
+    "Parts copyright André Majorel 1997-2003, GNU GPL v2",
+    "Parts copyright Matthew W. Miller 2000, GNU GPL v2",
+    "Parts written by Raphaël Quinet, public domain",
+    "Parts written by Brendon Wyber, public domain",
+    0
 };
-
--- a/src/dependcy.cc	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/dependcy.cc	Sat Sep 24 14:16:04 2011 +0300
@@ -28,29 +28,28 @@
 */
 
 
-#include "yadex.h"  /* Just to force a recompile when you ./configure again */
+#include "yadex.h"		/* Just to force a recompile when you ./configure again */
 #include "dependcy.h"
 #include "serialnum.h"
 
 
-Dependency::Dependency (Serial_num *sn)
+Dependency::Dependency(Serial_num * sn)
 {
-  serial_num  = sn;
-  token_valid = false;
+    serial_num = sn;
+    token_valid = false;
 }
 
 
-bool Dependency::outdated ()
+bool Dependency::outdated()
 {
-  if (! token_valid)
-    return true;
-  return serial_num->outdated (token);
+    if (!token_valid)
+	return true;
+    return serial_num->outdated(token);
 }
 
 
-void Dependency::update ()
+void Dependency::update()
 {
-  serial_num->update (token);
-  token_valid = true;
+    serial_num->update(token);
+    token_valid = true;
 }
-
--- a/src/dependcy.h	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/dependcy.h	Sat Sep 24 14:16:04 2011 +0300
@@ -22,26 +22,24 @@
    call Dependency::update(). */
 
 
-#ifndef YH_DEPENDCY  /* DO NOT INSERT ANYTHING BEFORE THIS LINE */
+#ifndef YH_DEPENDCY		/* DO NOT INSERT ANYTHING BEFORE THIS LINE */
 #define YH_DEPENDCY
 
 
-class Serial_num;			// Defined in serialnum.h
+class Serial_num;		// Defined in serialnum.h
 typedef unsigned long serial_num_t;	// Copied from serialnum.h
 
 
 class Dependency
 {
-  public :
-    Dependency (Serial_num *sn);
-    bool outdated ();
-    void update ();
+    public: Dependency(Serial_num * sn);
+    bool outdated();
+    void update();
 
-  private :
-    Serial_num   *serial_num;
-    serial_num_t  token;
-    bool          token_valid;
+      private: Serial_num * serial_num;
+    serial_num_t token;
+    bool token_valid;
 };
 
 
-#endif  /* DO NOT ADD ANYTHING AFTER THIS LINE */
+#endif /* DO NOT ADD ANYTHING AFTER THIS LINE */
--- a/src/dialog.cc	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/dialog.cc	Sat Sep 24 14:16:04 2011 +0300
@@ -41,65 +41,66 @@
  *
  *	Return zero for "no", non-zero for "yes".
  */
-bool Confirm (int x0, int y0, const char *prompt1, const char *prompt2)
+bool Confirm(int x0, int y0, const char *prompt1, const char *prompt2)
 {
-  const char *const prompt3 = "Press [Y] to confirm, [N] to cancel...";
-  size_t maxlen;
-  double n_lines_of_text;
-  int width;
-  int height;
-  int text_x0;
-  int text_x1;
-  int x1;
-  int text_y0;
-  int text_y1;
-  int y1;
-  bool rc;
+    const char *const prompt3 = "Press [Y] to confirm, [N] to cancel...";
+    size_t maxlen;
+    double n_lines_of_text;
+    int width;
+    int height;
+    int text_x0;
+    int text_x1;
+    int x1;
+    int text_y0;
+    int text_y1;
+    int y1;
+    bool rc;
 
-  maxlen = strlen (prompt3);
-  if (strlen (prompt1) > maxlen)
-    maxlen = strlen (prompt1);
-  if (prompt2 != NULL && strlen (prompt2) > maxlen)
-    maxlen = strlen (prompt2);
-  n_lines_of_text = (prompt2 == NULL ? 2.5 : 3.5);
-  width = 2 * BOX_BORDER + 2 * WIDE_HSPACING + maxlen * FONTW;
-  height = 2 * BOX_BORDER + 2 * WIDE_VSPACING + (int) (n_lines_of_text * FONTH);
-  if (x0 < 0)
-    x0 = (ScrMaxX - width) / 2;
-  if (y0 < 0)
-    y0 = (ScrMaxY - height) / 2;
-  text_x0 = x0 + BOX_BORDER + WIDE_HSPACING;
-  text_x1 = text_x0 + maxlen * FONTW - 1;
-  x1      = text_x1 + WIDE_HSPACING + BOX_BORDER;
-  text_y0 = y0 + BOX_BORDER + WIDE_VSPACING;
-  text_y1 = text_y0 + (int) (n_lines_of_text * FONTH) - 1;
-  y1      = text_y1 + WIDE_HSPACING + BOX_BORDER;
-  for (bool first_time = true; ; first_time = false)
-  {
-    if (first_time || is.key == YE_EXPOSE)
+    maxlen = strlen(prompt3);
+    if (strlen(prompt1) > maxlen)
+	maxlen = strlen(prompt1);
+    if (prompt2 != NULL && strlen(prompt2) > maxlen)
+	maxlen = strlen(prompt2);
+    n_lines_of_text = (prompt2 == NULL ? 2.5 : 3.5);
+    width = 2 * BOX_BORDER + 2 * WIDE_HSPACING + maxlen * FONTW;
+    height =
+	2 * BOX_BORDER + 2 * WIDE_VSPACING + (int) (n_lines_of_text * FONTH);
+    if (x0 < 0)
+	x0 = (ScrMaxX - width) / 2;
+    if (y0 < 0)
+	y0 = (ScrMaxY - height) / 2;
+    text_x0 = x0 + BOX_BORDER + WIDE_HSPACING;
+    text_x1 = text_x0 + maxlen * FONTW - 1;
+    x1 = text_x1 + WIDE_HSPACING + BOX_BORDER;
+    text_y0 = y0 + BOX_BORDER + WIDE_VSPACING;
+    text_y1 = text_y0 + (int) (n_lines_of_text * FONTH) - 1;
+    y1 = text_y1 + WIDE_HSPACING + BOX_BORDER;
+    for (bool first_time = true;; first_time = false)
     {
-      DrawScreenBox3D (x0, y0, x1, y1);
-      set_colour (WHITE);
-      DrawScreenText (text_x0, text_y0, prompt1);
-      if (prompt2 != NULL)
-	DrawScreenText (text_x0, text_y0 + FONTH, prompt2);
-      set_colour (WINTITLE);
-      DrawScreenText (text_x0, text_y1 - FONTH - 1, prompt3);
+	if (first_time || is.key == YE_EXPOSE)
+	{
+	    DrawScreenBox3D(x0, y0, x1, y1);
+	    set_colour(WHITE);
+	    DrawScreenText(text_x0, text_y0, prompt1);
+	    if (prompt2 != NULL)
+		DrawScreenText(text_x0, text_y0 + FONTH, prompt2);
+	    set_colour(WINTITLE);
+	    DrawScreenText(text_x0, text_y1 - FONTH - 1, prompt3);
+	}
+	get_input_status();
+	if (is.key == 'y' || is.key == 'Y' || is.key == YK_RETURN)
+	{
+	    rc = true;
+	    break;
+	}
+	if (is.key == 'n' || is.key == 'N' || is.key == YK_ESC)
+	{
+	    rc = false;
+	    break;
+	}
     }
-    get_input_status ();
-    if (is.key == 'y' || is.key == 'Y' || is.key == YK_RETURN)
-    {
-      rc = true;
-      break;
-    }
-    if (is.key == 'n' || is.key == 'N' || is.key == YK_ESC)
-    {
-      rc = false;
-      break;
-    }
-  }
-  is.key = 0;  // Shouldn't have to do that but EditorLoop() is broken
-  return rc;
+    is.key = 0;			// Shouldn't have to do that but EditorLoop() is broken
+    return rc;
 }
 
 
@@ -108,19 +109,19 @@
  *
  *	Return zero for "no", non-zero for "yes".
  */
-int Confirm2 (int x0, int y0, confirm_t *confirm_flag,
-   const char *prompt1, const char *prompt2)
+int Confirm2(int x0, int y0, confirm_t * confirm_flag,
+	     const char *prompt1, const char *prompt2)
 {
-  int r;
+    int r;
 
-  if (*confirm_flag == YC_YES)
-    return 1;
-  if (*confirm_flag == YC_NO)
-    return 0;
-  r = Confirm (x0, y0, prompt1, prompt2);
-  if (*confirm_flag == YC_ASK_ONCE)
-    *confirm_flag = r ? YC_YES : YC_NO;  // We won't ask again
-  return r;
+    if (*confirm_flag == YC_YES)
+	return 1;
+    if (*confirm_flag == YC_NO)
+	return 0;
+    r = Confirm(x0, y0, prompt1, prompt2);
+    if (*confirm_flag == YC_ASK_ONCE)
+	*confirm_flag = r ? YC_YES : YC_NO;	// We won't ask again
+    return r;
 }
 
 
@@ -130,46 +131,47 @@
  *	Display a notification and wait for a key (prompt2 may
  *	be NULL)
  */
-void Notify (int x0, int y0, const char *prompt1, const char *prompt2)
+void Notify(int x0, int y0, const char *prompt1, const char *prompt2)
 {
-  const char *const prompt3 = "Press any key to continue...";
-  size_t maxlen;
-  double n_lines_of_text;
-  int width;
-  int height;
-  int text_x0;
-  int text_x1;
-  int x1;
-  int text_y0;
-  int text_y1;
-  int y1;
+    const char *const prompt3 = "Press any key to continue...";
+    size_t maxlen;
+    double n_lines_of_text;
+    int width;
+    int height;
+    int text_x0;
+    int text_x1;
+    int x1;
+    int text_y0;
+    int text_y1;
+    int y1;
 
-  maxlen = strlen (prompt3);
-  if (strlen (prompt1) > maxlen)
-    maxlen = strlen (prompt1);
-  if (prompt2 != NULL && strlen (prompt2) > maxlen)
-    maxlen = strlen (prompt2);
-  n_lines_of_text = (prompt2 == NULL ? 2.5 : 3.5);
-  width = 2 * BOX_BORDER + 2 * WIDE_HSPACING + maxlen * FONTW;
-  height = 2 * BOX_BORDER + 2 * WIDE_VSPACING + (int) (n_lines_of_text * FONTH);
-  if (x0 < 0)
-    x0 = (ScrMaxX - width) / 2;
-  if (y0 < 0)
-    y0 = (ScrMaxY - height) / 2;
-  text_x0 = x0 + BOX_BORDER + WIDE_HSPACING;
-  text_x1 = text_x0 + maxlen * FONTW - 1;
-  x1      = text_x1 + WIDE_HSPACING + BOX_BORDER;
-  text_y0 = y0 + BOX_BORDER + WIDE_VSPACING;
-  text_y1 = text_y0 + (int) (n_lines_of_text * FONTH) - 1;
-  y1      = text_y1 + WIDE_HSPACING + BOX_BORDER;
-  DrawScreenBox3D (x0, y0, x1, y1);
-  set_colour (WHITE);
-  DrawScreenText (text_x0, text_y0, prompt1);
-  if (prompt2 != NULL)
-    DrawScreenText (text_x0, text_y0 + FONTH, prompt2);
-  set_colour (WINTITLE);
-  DrawScreenText (text_x0, text_y1 - FONTH - 1, prompt3);
-  get_key_or_click ();
+    maxlen = strlen(prompt3);
+    if (strlen(prompt1) > maxlen)
+	maxlen = strlen(prompt1);
+    if (prompt2 != NULL && strlen(prompt2) > maxlen)
+	maxlen = strlen(prompt2);
+    n_lines_of_text = (prompt2 == NULL ? 2.5 : 3.5);
+    width = 2 * BOX_BORDER + 2 * WIDE_HSPACING + maxlen * FONTW;
+    height =
+	2 * BOX_BORDER + 2 * WIDE_VSPACING + (int) (n_lines_of_text * FONTH);
+    if (x0 < 0)
+	x0 = (ScrMaxX - width) / 2;
+    if (y0 < 0)
+	y0 = (ScrMaxY - height) / 2;
+    text_x0 = x0 + BOX_BORDER + WIDE_HSPACING;
+    text_x1 = text_x0 + maxlen * FONTW - 1;
+    x1 = text_x1 + WIDE_HSPACING + BOX_BORDER;
+    text_y0 = y0 + BOX_BORDER + WIDE_VSPACING;
+    text_y1 = text_y0 + (int) (n_lines_of_text * FONTH) - 1;
+    y1 = text_y1 + WIDE_HSPACING + BOX_BORDER;
+    DrawScreenBox3D(x0, y0, x1, y1);
+    set_colour(WHITE);
+    DrawScreenText(text_x0, text_y0, prompt1);
+    if (prompt2 != NULL)
+	DrawScreenText(text_x0, text_y0 + FONTH, prompt2);
+    set_colour(WINTITLE);
+    DrawScreenText(text_x0, text_y1 - FONTH - 1, prompt3);
+    get_key_or_click();
 }
 
 
@@ -181,50 +183,48 @@
  *	BUG: if result of formatting contains "%"'s, it will be
  *	formatted again...
  */
-void debmes (const char *fmt, ...)
+void debmes(const char *fmt, ...)
 {
-  char buf[200];
-  va_list arglist;
+    char buf[200];
+    va_list arglist;
 
-  if (Debug != 1)
-    return;
-  va_start (arglist, fmt);
-  y_vsnprintf (buf, sizeof buf, fmt, arglist);
-  Notify (-1, -1, buf, NULL);
+    if (Debug != 1)
+	return;
+    va_start(arglist, fmt);
+    y_vsnprintf(buf, sizeof buf, fmt, arglist);
+    Notify(-1, -1, buf, NULL);
 }
 
 
 /*
  *	DisplayMessage - clear the screen and display a message
  */
-void DisplayMessage (int x0, int y0, const char *msg, ...)
+void DisplayMessage(int x0, int y0, const char *msg, ...)
 {
-  char prompt[120];
-  va_list args;
+    char prompt[120];
+    va_list args;
 
-  va_start (args, msg);
-  y_vsnprintf (prompt, sizeof prompt, msg, args);
-  int width = 2 * BOX_BORDER + 2 * WIDE_HSPACING + FONTW * strlen (prompt);
-  int height = 2 * BOX_BORDER + 2 * WIDE_VSPACING + FONTH;
-  if (x0 < 0)
-    x0 = (ScrMaxX - width) / 2;
-  if (y0 < 0)
-    y0 = (ScrMaxY - height) / 2;
-  DrawScreenBox3D (x0, y0, x0 + width - 1, y0 + height - 1);
-  push_colour (WINFG);
-  DrawScreenText (x0 + BOX_BORDER + WIDE_HSPACING,
-    y0 + BOX_BORDER + WIDE_VSPACING, prompt);
-  pop_colour ();
-  update_display();
+    va_start(args, msg);
+    y_vsnprintf(prompt, sizeof prompt, msg, args);
+    int width = 2 * BOX_BORDER + 2 * WIDE_HSPACING + FONTW * strlen(prompt);
+    int height = 2 * BOX_BORDER + 2 * WIDE_VSPACING + FONTH;
+    if (x0 < 0)
+	x0 = (ScrMaxX - width) / 2;
+    if (y0 < 0)
+	y0 = (ScrMaxY - height) / 2;
+    DrawScreenBox3D(x0, y0, x0 + width - 1, y0 + height - 1);
+    push_colour(WINFG);
+    DrawScreenText(x0 + BOX_BORDER + WIDE_HSPACING,
+		   y0 + BOX_BORDER + WIDE_VSPACING, prompt);
+    pop_colour();
+    update_display();
 }
 
 
 /*
  *	NotImplemented - make the user angry...
  */
-void NotImplemented (void)
+void NotImplemented(void)
 {
-  Notify (-1, -1, "This function is not implemented... Yet!", NULL);
+    Notify(-1, -1, "This function is not implemented... Yet!", NULL);
 }
-
-
--- a/src/dialog.h	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/dialog.h	Sat Sep 24 14:16:04 2011 +0300
@@ -5,12 +5,10 @@
  */
 
 
-bool Confirm (int, int, const char *, const char *);
-int Confirm2 (int x0, int y0, confirm_t *confirm_flag,
-   const char *prompt1, const char *prompt2);
-void Notify (int, int, const char *, const char *);
-void debmes (const char *fmt, ...);
-void DisplayMessage (int, int, const char *, ...);
-void NotImplemented (void);
-
-
+bool Confirm(int, int, const char *, const char *);
+int Confirm2(int x0, int y0, confirm_t * confirm_flag,
+	     const char *prompt1, const char *prompt2);
+void Notify(int, int, const char *, const char *);
+void debmes(const char *fmt, ...);
+void DisplayMessage(int, int, const char *, ...);
+void NotImplemented(void);
--- a/src/disppic.cc	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/disppic.cc	Sat Sep 24 14:16:04 2011 +0300
@@ -45,49 +45,43 @@
  *
  *	A wrapper for LoadPicture() and Sticker.load()/draw().
  */
-void display_pic (hookfunc_comm_t *c)
+void display_pic(hookfunc_comm_t * c)
 {
-  int width  = c->x1 - c->x0 + 1;
-  int height = c->y1 - c->y0 + 1;
-  Lump_loc loc;
+    int width = c->x1 - c->x0 + 1;
+    int height = c->y1 - c->y0 + 1;
+    Lump_loc loc;
 
-  c->img.clear ();
-  c->img.set_opaque (false);
-  if (c->flags & HOOK_PATCH)
-    patch_dir.loc_by_name (c->name, loc);
-  else if ((c->flags & HOOK_SPRITE) && (c->flags & HOOK_ROOT))
-    wad_res.sprites.loc_by_root (c->name, loc);
-  else if ((c->flags & HOOK_SPRITE) && ! (c->flags & HOOK_ROOT))
-    wad_res.sprites.loc_by_name (c->name, loc);
-  if (! LoadPicture (c->img,
-    c->name,
-    loc,
-    0, // Not very clean, should use c->xofs but *WithFunc doesn't set it
-    0, // Not very clean, should use c->yofs but *WithFunc doesn't set it
-    &c->width,
-    &c->height))
-  {
-    c->disp_x0 = c->x0 + (width - c->width) / 2;
-    c->disp_y0 = c->y0 + (height - c->height) / 2;
-    c->disp_x1 = c->disp_x0 + c->width - 1;
-    c->disp_y1 = c->disp_y0 + c->height - 1;
-    c->flags |= HOOK_SIZE_VALID;
-    c->lump_loc = loc;
-    c->flags |= HOOK_LOC_VALID;
-    if (c->flags & HOOK_SPECTRAL)
-      spectrify_img (c->img);
-    Sticker sticker (c->img, true);  // Use opaque because it's faster
-    sticker.draw (drw, 't', c->disp_x0, c->disp_y0);
-    c->flags |= HOOK_DRAWN;
-  }
-  else
-  {
-    // Drew nothing (negative width and height)
-    c->disp_x0 = c->x0 + 1;
-    c->disp_y0 = c->y0 + 1;
-    c->disp_x1 = c->x0;
-    c->disp_y1 = c->y0;
-  }
+    c->img.clear();
+    c->img.set_opaque(false);
+    if (c->flags & HOOK_PATCH)
+	patch_dir.loc_by_name(c->name, loc);
+    else if ((c->flags & HOOK_SPRITE) && (c->flags & HOOK_ROOT))
+	wad_res.sprites.loc_by_root(c->name, loc);
+    else if ((c->flags & HOOK_SPRITE) && !(c->flags & HOOK_ROOT))
+	wad_res.sprites.loc_by_name(c->name, loc);
+    if (!LoadPicture(c->img, c->name, loc, 0,	// Not very clean, should use c->xofs but *WithFunc doesn't set it
+		     0,		// Not very clean, should use c->yofs but *WithFunc doesn't set it
+		     &c->width, &c->height))
+    {
+	c->disp_x0 = c->x0 + (width - c->width) / 2;
+	c->disp_y0 = c->y0 + (height - c->height) / 2;
+	c->disp_x1 = c->disp_x0 + c->width - 1;
+	c->disp_y1 = c->disp_y0 + c->height - 1;
+	c->flags |= HOOK_SIZE_VALID;
+	c->lump_loc = loc;
+	c->flags |= HOOK_LOC_VALID;
+	if (c->flags & HOOK_SPECTRAL)
+	    spectrify_img(c->img);
+	Sticker sticker(c->img, true);	// Use opaque because it's faster
+	sticker.draw(drw, 't', c->disp_x0, c->disp_y0);
+	c->flags |= HOOK_DRAWN;
+    }
+    else
+    {
+	// Drew nothing (negative width and height)
+	c->disp_x0 = c->x0 + 1;
+	c->disp_y0 = c->y0 + 1;
+	c->disp_x1 = c->x0;
+	c->disp_y1 = c->y0;
+    }
 }
-
-
--- a/src/disppic.h	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/disppic.h	Sat Sep 24 14:16:04 2011 +0300
@@ -4,14 +4,14 @@
  */
 
 
-#ifndef YH_DISPPIC  /* DO NOT INSERT ANYTHING BEFORE THIS LINE */
+#ifndef YH_DISPPIC		/* DO NOT INSERT ANYTHING BEFORE THIS LINE */
 #define YH_DISPPIC
 
 
 #include "lists.h"
 
 
-void display_pic (hookfunc_comm_t *c);
+void display_pic(hookfunc_comm_t * c);
 
 
-#endif  /* DO NOT ADD ANYTHING AFTER THIS LINE */
+#endif /* DO NOT ADD ANYTHING AFTER THIS LINE */
--- a/src/drawmap.cc	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/drawmap.cc	Sat Sep 24 14:16:04 2011 +0300
@@ -33,12 +33,12 @@
 #include <map>
 #include <vector>
 #ifdef Y_X11
-#  include <X11/Xlib.h>
+#include <X11/Xlib.h>
 #endif
 #include "_edit.h"
-#include "disppic.h"  /* Sprites */
+#include "disppic.h"		/* Sprites */
 #include "drawmap.h"
-#include "game.h"     /* Sprites */
+#include "game.h"		/* Sprites */
 #include "gfx.h"
 #include "imgscale.h"
 #include "imgspect.h"
@@ -52,12 +52,12 @@
 #include "wadres.h"
 
 
-static void draw_grid (edit_t *e);
-static void draw_vertices (edit_t *e);
-static void draw_linedefs (edit_t *e);
-static void draw_things_squares (edit_t *e);
-static void draw_things_sprites (edit_t *e);
-static void draw_obj_no (int x, int y, int obj_no, acolour_t c);
+static void draw_grid(edit_t * e);
+static void draw_vertices(edit_t * e);
+static void draw_linedefs(edit_t * e);
+static void draw_things_squares(edit_t * e);
+static void draw_things_sprites(edit_t * e);
+static void draw_obj_no(int x, int y, int obj_no, acolour_t c);
 
 
 /*
@@ -68,38 +68,39 @@
  *	  plot [0:10] x                                          
  *	  replot log(x+1.46)/log(1.5)-log(2.46)/log(1.5)+1
  */
-int vertex_radius (double scale)
+int vertex_radius(double scale)
 {
 #if 0
-  static double last_scale = 0;
-  static int    last_result = 0;
+    static double last_scale = 0;
+    static int last_result = 0;
 
-  if (scale == last_scale)
-    return last_result;
+    if (scale == last_scale)
+	return last_result;
 
-  const int    VERTEX_PIXELS  = 5;
+    const int VERTEX_PIXELS = 5;
 
-  // The scale past which we switch from linear to logarithmic.
-  const double crossover      = 0.1;
+    // The scale past which we switch from linear to logarithmic.
+    const double crossover = 0.1;
 
-  // The base of the log. The higher, the stronger the effect.
-  const double base           = 1.4;
+    // The base of the log. The higher, the stronger the effect.
+    const double base = 1.4;
 
-  /* The point at which the derivative of log{base}(x) is 1.
-     This is where we want the crossover to occur. */
-  const double knee_x         = 1 / log (base);
-  const double knee_y         = log (knee_x) / log (base);
+    /* The point at which the derivative of log{base}(x) is 1.
+       This is where we want the crossover to occur. */
+    const double knee_x = 1 / log(base);
+    const double knee_y = log(knee_x) / log(base);
 
-  double factor;
-  if (scale <= crossover)
-    factor = scale;
-  else
-    factor = crossover + log (scale -crossover + knee_x) / log (base) - knee_y;
-  last_result = (int) (VERTEX_PIXELS * factor + 0.5);
-  return last_result;
+    double factor;
+    if (scale <= crossover)
+	factor = scale;
+    else
+	factor =
+	    crossover + log(scale - crossover + knee_x) / log(base) - knee_y;
+    last_result = (int) (VERTEX_PIXELS * factor + 0.5);
+    return last_result;
 #else
-  const int VERTEX_PIXELS = 6;
-  return (int) (VERTEX_PIXELS * (0.2 + scale / 2));
+    const int VERTEX_PIXELS = 6;
+    return (int) (VERTEX_PIXELS * (0.2 + scale / 2));
 #endif
 }
 
@@ -108,479 +109,479 @@
   draw the actual game map
 */
 
-void draw_map (edit_t *e) /* SWAP! */
+void draw_map(edit_t * e)	/* SWAP! */
 {
-  int mapx0 = MAPX (0);
-  int mapx9 = MAPX (ScrMaxX);
-  int mapy0 = MAPY (ScrMaxY);
-  int mapy9 = MAPY (0);
-  int n;
+    int mapx0 = MAPX(0);
+    int mapx9 = MAPX(ScrMaxX);
+    int mapy0 = MAPY(ScrMaxY);
+    int mapy9 = MAPY(0);
+    int n;
 
 
-  // Draw the grid first since it's in the background
-  draw_grid (e);
+    // Draw the grid first since it's in the background
+    draw_grid(e);
 
-  if (e->global)
-  {
-    draw_linedefs (e);
-    if (e->show_things_sprites)
-      draw_things_sprites (e);
+    if (e->global)
+    {
+	draw_linedefs(e);
+	if (e->show_things_sprites)
+	    draw_things_sprites(e);
+	else
+	    draw_things_squares(e);
+	draw_vertices(e);
+    }
     else
-      draw_things_squares (e);
-    draw_vertices (e);
-  }
-  else
-  {
-    if (e->obj_type != OBJ_THINGS)
-      draw_things_squares (e);
-    draw_linedefs (e);
-    if (e->obj_type == OBJ_VERTICES)
-      draw_vertices (e);
-    if (e->obj_type == OBJ_THINGS)
     {
-      if (e->show_things_sprites)
-	draw_things_sprites (e);
-      else
-	draw_things_squares (e);
+	if (e->obj_type != OBJ_THINGS)
+	    draw_things_squares(e);
+	draw_linedefs(e);
+	if (e->obj_type == OBJ_VERTICES)
+	    draw_vertices(e);
+	if (e->obj_type == OBJ_THINGS)
+	{
+	    if (e->show_things_sprites)
+		draw_things_sprites(e);
+	    else
+		draw_things_squares(e);
+	}
     }
-  }
 
 
-  // Draw the things numbers
-  if (e->obj_type == OBJ_THINGS && e->show_object_numbers)
-  {
-    for (n = 0; n < NumThings; n++)
+    // Draw the things numbers
+    if (e->obj_type == OBJ_THINGS && e->show_object_numbers)
     {
-      int mapx = Things[n].xpos;
-      int mapy = Things[n].ypos;
-      if (mapx < mapx0 || mapx > mapx9 || mapy < mapy0 || mapy > mapy9)
-	continue;
-      draw_obj_no (SCREENX (mapx) + FONTW, SCREENY (mapy) + 2, n, THING_NO);
+	for (n = 0; n < NumThings; n++)
+	{
+	    int mapx = Things[n].xpos;
+	    int mapy = Things[n].ypos;
+	    if (mapx < mapx0 || mapx > mapx9 || mapy < mapy0 || mapy > mapy9)
+		continue;
+	    draw_obj_no(SCREENX(mapx) + FONTW, SCREENY(mapy) + 2, n,
+			THING_NO);
+	}
     }
-  }
 
-  // Draw the sector numbers
-  if (e->obj_type == OBJ_SECTORS && e->show_object_numbers)
-  {
-    int xoffset = - FONTW / 2;
-
-    for (n = 0; n < NumSectors; n++)
+    // Draw the sector numbers
+    if (e->obj_type == OBJ_SECTORS && e->show_object_numbers)
     {
-      int mapx;
-      int mapy;
-      centre_of_sector (n, &mapx, &mapy);
-      if (mapx >= mapx0 && mapx <= mapx9 && mapy >= mapy0 && mapy <= mapy9)
-	draw_obj_no (SCREENX (mapx) + xoffset, SCREENY (mapy) - FONTH / 2, n,
-	  SECTOR_NO);
-      if (n == 10 || n == 100 || n == 1000 || n == 10000)
-	xoffset -= FONTW / 2;
+	int xoffset = -FONTW / 2;
+
+	for (n = 0; n < NumSectors; n++)
+	{
+	    int mapx;
+	    int mapy;
+	    centre_of_sector(n, &mapx, &mapy);
+	    if (mapx >= mapx0 && mapx <= mapx9 && mapy >= mapy0
+		&& mapy <= mapy9)
+		draw_obj_no(SCREENX(mapx) + xoffset,
+			    SCREENY(mapy) - FONTH / 2, n, SECTOR_NO);
+	    if (n == 10 || n == 100 || n == 1000 || n == 10000)
+		xoffset -= FONTW / 2;
+	}
     }
-  }
 }
 
 
 /*
  *	draw_grid - draw the grid in the background of the edit window
  */
-static void draw_grid (edit_t *e)
+static void draw_grid(edit_t * e)
 {
-  if (! e->grid_shown)
-    return;
-  
-  int mapx0   = MAPX (0);
-  int mapx1   = MAPX (ScrMaxX);
-  int mapy0   = MAPY (ScrMaxY);
-  int mapy1   = MAPY (0);
+    if (!e->grid_shown)
+	return;
 
-  int grid_step_1 = e->grid_step;	// Map units between dots
-  int grid_step_2 = 4 * grid_step_1;	// Map units between dim lines
-  int grid_step_3 = 4 * grid_step_2;	// Map units between bright lines
-  int grid_step_4 = 4 * grid_step_3;	// Map units between brighter lines
+    int mapx0 = MAPX(0);
+    int mapx1 = MAPX(ScrMaxX);
+    int mapy0 = MAPY(ScrMaxY);
+    int mapy1 = MAPY(0);
+
+    int grid_step_1 = e->grid_step;	// Map units between dots
+    int grid_step_2 = 4 * grid_step_1;	// Map units between dim lines
+    int grid_step_3 = 4 * grid_step_2;	// Map units between bright lines
+    int grid_step_4 = 4 * grid_step_3;	// Map units between brighter lines
 
-  {
-    set_colour (GRID2V);
-    int mapx0_2 = (mapx0 / grid_step_2) * grid_step_2;
-    if (mapx0_2 < mapx0)
-      mapx0_2 += grid_step_2;
-    for (int i = mapx0_2; i <= mapx1; i += grid_step_2)
-      if (i % grid_step_3 != 0)
-	DrawMapLine (i, mapy0, i, mapy1);
-  }
+    {
+	set_colour(GRID2V);
+	int mapx0_2 = (mapx0 / grid_step_2) * grid_step_2;
+	if (mapx0_2 < mapx0)
+	    mapx0_2 += grid_step_2;
+	for (int i = mapx0_2; i <= mapx1; i += grid_step_2)
+	    if (i % grid_step_3 != 0)
+		DrawMapLine(i, mapy0, i, mapy1);
+    }
 
-  {
-    set_colour (GRID2H);
-    int mapy0_2 = (mapy0 / grid_step_2) * grid_step_2;
-    if (mapy0_2 < mapy0)
-      mapy0_2 += grid_step_2;
-    for (int j = mapy0_2; j <=  mapy1; j += grid_step_2)
-      if (j % grid_step_3 != 0)
-	DrawMapLine (mapx0, j, mapx1, j);
-  }
+    {
+	set_colour(GRID2H);
+	int mapy0_2 = (mapy0 / grid_step_2) * grid_step_2;
+	if (mapy0_2 < mapy0)
+	    mapy0_2 += grid_step_2;
+	for (int j = mapy0_2; j <= mapy1; j += grid_step_2)
+	    if (j % grid_step_3 != 0)
+		DrawMapLine(mapx0, j, mapx1, j);
+    }
 
-  {
-    set_colour (GRID3V);
-    int mapx0_3 = (mapx0 / grid_step_3) * grid_step_3;
-    if (mapx0_3 < mapx0)
-      mapx0_3 += grid_step_3;
-    for (int i = mapx0_3; i <= mapx1; i += grid_step_3)
-      if (i % grid_step_4 != 0)
-	DrawMapLine (i, mapy0, i, mapy1);
-  }
+    {
+	set_colour(GRID3V);
+	int mapx0_3 = (mapx0 / grid_step_3) * grid_step_3;
+	if (mapx0_3 < mapx0)
+	    mapx0_3 += grid_step_3;
+	for (int i = mapx0_3; i <= mapx1; i += grid_step_3)
+	    if (i % grid_step_4 != 0)
+		DrawMapLine(i, mapy0, i, mapy1);
+    }
 
-  {
-    set_colour (GRID3H);
-    int mapy0_3 = (mapy0 / grid_step_3) * grid_step_3;
-    if (mapy0_3 < mapy0)
-      mapy0_3 += grid_step_3;
-    for (int j = mapy0_3; j <=  mapy1; j += grid_step_3)
-      if (j % grid_step_4 != 0)
-	DrawMapLine (mapx0, j, mapx1, j);
-  }
+    {
+	set_colour(GRID3H);
+	int mapy0_3 = (mapy0 / grid_step_3) * grid_step_3;
+	if (mapy0_3 < mapy0)
+	    mapy0_3 += grid_step_3;
+	for (int j = mapy0_3; j <= mapy1; j += grid_step_3)
+	    if (j % grid_step_4 != 0)
+		DrawMapLine(mapx0, j, mapx1, j);
+    }
 
-  {
-    set_colour (GRID4V);
-    int mapx0_4 = (mapx0 / grid_step_4) * grid_step_4;
-    if (mapx0_4 < mapx0)
-      mapx0_4 += grid_step_4;
-    //printf ("MAPX(0): %d  mapx0_4: %d\n", MAPX(0), mapx0_4);  // DEBUG
-    for (int i = mapx0_4; i <= mapx1; i += grid_step_4)
-      DrawMapLine (i, mapy0, i, mapy1);
-  }
+    {
+	set_colour(GRID4V);
+	int mapx0_4 = (mapx0 / grid_step_4) * grid_step_4;
+	if (mapx0_4 < mapx0)
+	    mapx0_4 += grid_step_4;
+	//printf ("MAPX(0): %d  mapx0_4: %d\n", MAPX(0), mapx0_4);  // DEBUG
+	for (int i = mapx0_4; i <= mapx1; i += grid_step_4)
+	    DrawMapLine(i, mapy0, i, mapy1);
+    }
 
-  {
-    set_colour (GRID4H);
-    int mapy0_4 = (mapy0 / grid_step_4) * grid_step_4;
-    if (mapy0_4 < mapy0)
-      mapy0_4 += grid_step_4;
-    for (int j = mapy0_4; j <=  mapy1; j += grid_step_4)
-      DrawMapLine (mapx0, j, mapx1, j);
-  }
+    {
+	set_colour(GRID4H);
+	int mapy0_4 = (mapy0 / grid_step_4) * grid_step_4;
+	if (mapy0_4 < mapy0)
+	    mapy0_4 += grid_step_4;
+	for (int j = mapy0_4; j <= mapy1; j += grid_step_4)
+	    DrawMapLine(mapx0, j, mapx1, j);
+    }
 
-  {
-    int mapx0_1 = (mapx0 / grid_step_1) * grid_step_1;
-    if (mapx0_1 < mapx0)
-      mapx0_1 += grid_step_1;
-    int mapy0_1 = (mapy0 / grid_step_1) * grid_step_1;
-    if (mapy0_1 < mapy0)
-      mapy0_1 += grid_step_1;
+    {
+	int mapx0_1 = (mapx0 / grid_step_1) * grid_step_1;
+	if (mapx0_1 < mapx0)
+	    mapx0_1 += grid_step_1;
+	int mapy0_1 = (mapy0 / grid_step_1) * grid_step_1;
+	if (mapy0_1 < mapy0)
+	    mapy0_1 += grid_step_1;
 
 #ifdef Y_X11
-    // Optimisation for X: draw several points in one go
-    int npoints = (mapx1 - mapx0_1) / grid_step_1 + 1;
-    XPoint *points = (XPoint *) malloc (npoints * sizeof *points);
-    points[0].x = SCREENX (mapx0_1);
-    int n = 1;
-    int last_i = points[0].x;
-    for (int i = mapx0_1 + grid_step_1; i <= mapx1; i += grid_step_1)
-    {
-      if (n >= npoints)
-	nf_bug ("%d >= %d", n, npoints);
-      points[n].x = SCREENX (i) - last_i;
-      points[n].y = 0;
-      n++;
-      last_i = SCREENX (i);
+	// Optimisation for X: draw several points in one go
+	int npoints = (mapx1 - mapx0_1) / grid_step_1 + 1;
+	XPoint *points = (XPoint *) malloc(npoints * sizeof *points);
+	points[0].x = SCREENX(mapx0_1);
+	int n = 1;
+	int last_i = points[0].x;
+	for (int i = mapx0_1 + grid_step_1; i <= mapx1; i += grid_step_1)
+	{
+	    if (n >= npoints)
+		nf_bug("%d >= %d", n, npoints);
+	    points[n].x = SCREENX(i) - last_i;
+	    points[n].y = 0;
+	    n++;
+	    last_i = SCREENX(i);
+	}
+	npoints = n;
+	set_colour(GRID1);
+	for (int j = mapy0_1; j <= mapy1; j += grid_step_1)
+	{
+	    points[0].y = SCREENY(j);
+	    XDrawPoints(dpy, drw, gc, points, npoints, CoordModePrevious);
+	}
+	free(points);
+#else
+	// Generic code. Untested.
+	int npoints = (mapx1 - mapx0_1) / grid_step_1 + 1;
+	int dispx[npoints];
+	for (int n = 0; n < npoints; n++)
+	    dispx[n] = SCREENX(mapx0_1 + n * grid_step_1);
+	for (int j = mapy0_1; j <= mapy1; j += grid_step_1)
+	{
+	    int dispy = SCREENY(j);
+	    for (int n = 0; n < npoints; n++)
+	    {
+		draw_point(dispx[n], dispy);
+	    }
+	}
+#endif
     }
-    npoints = n;
-    set_colour (GRID1);
-    for (int j = mapy0_1; j <= mapy1; j += grid_step_1)
-    {
-      points[0].y = SCREENY (j);
-      XDrawPoints (dpy, drw, gc, points, npoints, CoordModePrevious);
-    }
-    free (points);
-#else
-    // Generic code. Untested.
-    int npoints = (mapx1 - mapx0_1) / grid_step_1 + 1;
-    int dispx[npoints];
-    for (int n = 0; n < npoints; n++)
-      dispx[n] = SCREENX (mapx0_1 + n * grid_step_1);
-    for (int j = mapy0_1; j <= mapy1; j += grid_step_1)
-    {
-      int dispy = SCREENY (j);
-      for (int n = 0; n < npoints; n++)
-      {
-	draw_point (dispx[n], dispy);
-      }
-    }
-#endif
-  }
 }
 
 
 /*
  *	draw_vertices - draw the vertices, and possibly their numbers
  */
-static void draw_vertices (edit_t *e)
+static void draw_vertices(edit_t * e)
 {
-  int mapx0 = MAPX (0);
-  int mapx9 = MAPX (ScrMaxX);
-  int mapy0 = MAPY (ScrMaxY);
-  int mapy9 = MAPY (0);
-  const int r = vertex_radius (Scale);
+    int mapx0 = MAPX(0);
+    int mapx9 = MAPX(ScrMaxX);
+    int mapy0 = MAPY(ScrMaxY);
+    int mapy9 = MAPY(0);
+    const int r = vertex_radius(Scale);
 
-  push_colour (LIGHTGREEN);
-  for (int n = 0; n < NumVertices; n++)
-  {
-    int mapx = Vertices[n].x;
-    int mapy = Vertices[n].y;
-    if (mapx >= mapx0 && mapx <= mapx9 && mapy >= mapy0 && mapy <= mapy9)
-    {
-      register int scrx = SCREENX (mapx);
-      register int scry = SCREENY (mapy);
-      DrawScreenLine (scrx - r, scry - r, scrx + r, scry + r);
-      DrawScreenLine (scrx + r, scry - r, scrx - r, scry + r);
-    }
-  }
-  if (e->show_object_numbers)
-  {
+    push_colour(LIGHTGREEN);
     for (int n = 0; n < NumVertices; n++)
     {
-      int mapx = Vertices[n].x;
-      int mapy = Vertices[n].y;
-      if (mapx >= mapx0 && mapx <= mapx9 && mapy >= mapy0 && mapy <= mapy9)
-      {
-	int x = (int) (SCREENX (mapx) + 2 * r);
-	int y = SCREENY (mapy) + 2;
-	draw_obj_no (x, y, n, VERTEX_NO);
-      }
+	int mapx = Vertices[n].x;
+	int mapy = Vertices[n].y;
+	if (mapx >= mapx0 && mapx <= mapx9 && mapy >= mapy0 && mapy <= mapy9)
+	{
+	    register int scrx = SCREENX(mapx);
+	    register int scry = SCREENY(mapy);
+	    DrawScreenLine(scrx - r, scry - r, scrx + r, scry + r);
+	    DrawScreenLine(scrx + r, scry - r, scrx - r, scry + r);
+	}
     }
-  }
-  pop_colour ();
+    if (e->show_object_numbers)
+    {
+	for (int n = 0; n < NumVertices; n++)
+	{
+	    int mapx = Vertices[n].x;
+	    int mapy = Vertices[n].y;
+	    if (mapx >= mapx0 && mapx <= mapx9 && mapy >= mapy0
+		&& mapy <= mapy9)
+	    {
+		int x = (int) (SCREENX(mapx) + 2 * r);
+		int y = SCREENY(mapy) + 2;
+		draw_obj_no(x, y, n, VERTEX_NO);
+	    }
+	}
+    }
+    pop_colour();
 }
 
 
 /*
  *	draw_linedefs - draw the linedefs
  */
-static void draw_linedefs (edit_t *e)
+static void draw_linedefs(edit_t * e)
 {
-  int mapx0 = MAPX (0);
-  int mapx9 = MAPX (ScrMaxX);
-  int mapy0 = MAPY (ScrMaxY);
-  int mapy9 = MAPY (0);
+    int mapx0 = MAPX(0);
+    int mapx9 = MAPX(ScrMaxX);
+    int mapy0 = MAPY(ScrMaxY);
+    int mapy9 = MAPY(0);
 
-  switch (e->obj_type)
-  {
-    case OBJ_THINGS:
+    switch (e->obj_type)
     {
-      int current_colour = INT_MIN;  /* Some impossible colour no. */
-      int new_colour;
-      
-      for (int n = 0; n < NumLineDefs; n++)
-      {
-	register int x1 = Vertices[LineDefs[n].start].x;
-	register int x2 = Vertices[LineDefs[n].end  ].x;
-	register int y1 = Vertices[LineDefs[n].start].y;
-	register int y2 = Vertices[LineDefs[n].end  ].y;
-	if (x1 < mapx0 && x2 < mapx0
-	 || x1 > mapx9 && x2 > mapx9
-	 || y1 < mapy0 && y2 < mapy0
-	 || y1 > mapy9 && y2 > mapy9)
-	  continue;
-	if (LineDefs[n].flags & 1)
-	  new_colour = WHITE;
-	else
-	  new_colour = LIGHTGREY;
-	if (new_colour != current_colour)
-	  set_colour (current_colour = new_colour);
-	DrawMapLine (x1, y1, x2, y2);
-      }
-      break;
-    }
+    case OBJ_THINGS:
+	{
+	    int current_colour = INT_MIN;	/* Some impossible colour no. */
+	    int new_colour;
+
+	    for (int n = 0; n < NumLineDefs; n++)
+	    {
+		register int x1 = Vertices[LineDefs[n].start].x;
+		register int x2 = Vertices[LineDefs[n].end].x;
+		register int y1 = Vertices[LineDefs[n].start].y;
+		register int y2 = Vertices[LineDefs[n].end].y;
+		if (x1 < mapx0 && x2 < mapx0
+		    || x1 > mapx9 && x2 > mapx9
+		    || y1 < mapy0 && y2 < mapy0 || y1 > mapy9 && y2 > mapy9)
+		    continue;
+		if (LineDefs[n].flags & 1)
+		    new_colour = WHITE;
+		else
+		    new_colour = LIGHTGREY;
+		if (new_colour != current_colour)
+		    set_colour(current_colour = new_colour);
+		DrawMapLine(x1, y1, x2, y2);
+	    }
+	    break;
+	}
 
     case OBJ_VERTICES:
-      set_colour (LIGHTGREY);
-      for (int n = 0; n < NumLineDefs; n++)
-      {
-	register int x1 = Vertices[LineDefs[n].start].x;
-	register int x2 = Vertices[LineDefs[n].end  ].x;
-	register int y1 = Vertices[LineDefs[n].start].y;
-	register int y2 = Vertices[LineDefs[n].end  ].y;
-	if (x1 < mapx0 && x2 < mapx0
-	 || x1 > mapx9 && x2 > mapx9
-	 || y1 < mapy0 && y2 < mapy0
-	 || y1 > mapy9 && y2 > mapy9)
-	  continue;
-	DrawMapVector (x1, y1, x2, y2);
-      }
-      break;
+	set_colour(LIGHTGREY);
+	for (int n = 0; n < NumLineDefs; n++)
+	{
+	    register int x1 = Vertices[LineDefs[n].start].x;
+	    register int x2 = Vertices[LineDefs[n].end].x;
+	    register int y1 = Vertices[LineDefs[n].start].y;
+	    register int y2 = Vertices[LineDefs[n].end].y;
+	    if (x1 < mapx0 && x2 < mapx0
+		|| x1 > mapx9 && x2 > mapx9
+		|| y1 < mapy0 && y2 < mapy0 || y1 > mapy9 && y2 > mapy9)
+		continue;
+	    DrawMapVector(x1, y1, x2, y2);
+	}
+	break;
 
     case OBJ_LINEDEFS:
-    {
-      int current_colour = INT_MIN;  /* Some impossible colour no. */
-      int new_colour;
+	{
+	    int current_colour = INT_MIN;	/* Some impossible colour no. */
+	    int new_colour;
 
-      for (int n = 0; n < NumLineDefs; n++)
-      {
-	register int x1 = Vertices[LineDefs[n].start].x;
-	register int x2 = Vertices[LineDefs[n].end  ].x;
-	register int y1 = Vertices[LineDefs[n].start].y;
-	register int y2 = Vertices[LineDefs[n].end  ].y;
-	if (x1 < mapx0 && x2 < mapx0
-	 || x1 > mapx9 && x2 > mapx9
-	 || y1 < mapy0 && y2 < mapy0
-	 || y1 > mapy9 && y2 > mapy9)
-	  continue;
-	if (LineDefs[n].type != 0)  /* AYM 19980207: was "> 0" */
-	{
-	  if (LineDefs[n].tag != 0)  /* AYM 19980207: was "> 0" */
-	    new_colour = LIGHTMAGENTA;
-	  else
-	    new_colour = LIGHTGREEN;
-	}
-	else if (LineDefs[n].flags & 1)
-	  new_colour = WHITE;
-	else
-	  new_colour = LIGHTGREY;
+	    for (int n = 0; n < NumLineDefs; n++)
+	    {
+		register int x1 = Vertices[LineDefs[n].start].x;
+		register int x2 = Vertices[LineDefs[n].end].x;
+		register int y1 = Vertices[LineDefs[n].start].y;
+		register int y2 = Vertices[LineDefs[n].end].y;
+		if (x1 < mapx0 && x2 < mapx0
+		    || x1 > mapx9 && x2 > mapx9
+		    || y1 < mapy0 && y2 < mapy0 || y1 > mapy9 && y2 > mapy9)
+		    continue;
+		if (LineDefs[n].type != 0)	/* AYM 19980207: was "> 0" */
+		{
+		    if (LineDefs[n].tag != 0)	/* AYM 19980207: was "> 0" */
+			new_colour = LIGHTMAGENTA;
+		    else
+			new_colour = LIGHTGREEN;
+		}
+		else if (LineDefs[n].flags & 1)
+		    new_colour = WHITE;
+		else
+		    new_colour = LIGHTGREY;
 
-	// Signal errors by drawing the linedef in red. Needs work.
-	// Tag on a typeless linedef
-	if (LineDefs[n].type == 0 && LineDefs[n].tag != 0)
-	  new_colour = LIGHTRED;
-	// No first sidedef
-	if (! is_sidedef (LineDefs[n].sidedef1))
-	  new_colour = LIGHTRED;
-	// Bad second sidedef
-	if (! is_sidedef (LineDefs[n].sidedef2) && LineDefs[n].sidedef2 != -1)
-	  new_colour = LIGHTRED;
+		// Signal errors by drawing the linedef in red. Needs work.
+		// Tag on a typeless linedef
+		if (LineDefs[n].type == 0 && LineDefs[n].tag != 0)
+		    new_colour = LIGHTRED;
+		// No first sidedef
+		if (!is_sidedef(LineDefs[n].sidedef1))
+		    new_colour = LIGHTRED;
+		// Bad second sidedef
+		if (!is_sidedef(LineDefs[n].sidedef2)
+		    && LineDefs[n].sidedef2 != -1)
+		    new_colour = LIGHTRED;
 
-	if (new_colour != current_colour)
-	  set_colour (current_colour = new_colour);
-	DrawMapLine (x1, y1, x2, y2);
+		if (new_colour != current_colour)
+		    set_colour(current_colour = new_colour);
+		DrawMapLine(x1, y1, x2, y2);
 
-	if (e->show_object_numbers)
-	{
-	  int scnx0       = SCREENX (x1);
-	  int scnx1       = SCREENX (x2);
-	  int scny0       = SCREENY (y1);
-	  int scny1       = SCREENY (y2);
-	  int label_width = ((int) log10 (n) + 1) * FONTW;
-	  if (abs (scnx1 - scnx0) > label_width + 4
-	   || abs (scny1 - scny0) > label_width + 4)
-	  {
-	    int scnx = (scnx0 + scnx1) / 2 - label_width / 2;
-	    int scny = (scny0 + scny1) / 2 - FONTH / 2;
-	    draw_obj_no (scnx, scny, n, LINEDEF_NO);
-	  }
+		if (e->show_object_numbers)
+		{
+		    int scnx0 = SCREENX(x1);
+		    int scnx1 = SCREENX(x2);
+		    int scny0 = SCREENY(y1);
+		    int scny1 = SCREENY(y2);
+		    int label_width = ((int) log10(n) + 1) * FONTW;
+		    if (abs(scnx1 - scnx0) > label_width + 4
+			|| abs(scny1 - scny0) > label_width + 4)
+		    {
+			int scnx = (scnx0 + scnx1) / 2 - label_width / 2;
+			int scny = (scny0 + scny1) / 2 - FONTH / 2;
+			draw_obj_no(scnx, scny, n, LINEDEF_NO);
+		    }
+		}
+	    }
+	    break;
 	}
-      }
-      break;
-    }
 
     case OBJ_SECTORS:
-    {
-      int current_colour = INT_MIN;  /* Some impossible colour no. */
-      int new_colour;
+	{
+	    int current_colour = INT_MIN;	/* Some impossible colour no. */
+	    int new_colour;
 
-      for (int n = 0; n < NumLineDefs; n++)
-      {
-	register int x1 = Vertices[LineDefs[n].start].x;
-	register int x2 = Vertices[LineDefs[n].end  ].x;
-	register int y1 = Vertices[LineDefs[n].start].y;
-	register int y2 = Vertices[LineDefs[n].end  ].y;
-	if (x1 < mapx0 && x2 < mapx0
-	 || x1 > mapx9 && x2 > mapx9
-	 || y1 < mapy0 && y2 < mapy0
-	 || y1 > mapy9 && y2 > mapy9)
-	  continue;
-	int sd1 = OBJ_NO_NONE;
-	int sd2 = OBJ_NO_NONE;
-	int s1  = OBJ_NO_NONE;
-	int s2  = OBJ_NO_NONE;
-	// FIXME should flag negative sidedef numbers as errors
-	// FIXME should flag unused tag as errors
-	if ((sd1 = LineDefs[n].sidedef1) < 0 || sd1 >= NumSideDefs
-	  || (s1 = SideDefs[sd1].sector) < 0 || s1 >= NumSectors
-	  || (sd2 = LineDefs[n].sidedef2) >= NumSideDefs
-	  || sd2 >= 0 && ((s2 = SideDefs[sd2].sector) < 0
-			|| s2 >= NumSectors))
-	{
-	  new_colour = LIGHTRED;
+	    for (int n = 0; n < NumLineDefs; n++)
+	    {
+		register int x1 = Vertices[LineDefs[n].start].x;
+		register int x2 = Vertices[LineDefs[n].end].x;
+		register int y1 = Vertices[LineDefs[n].start].y;
+		register int y2 = Vertices[LineDefs[n].end].y;
+		if (x1 < mapx0 && x2 < mapx0
+		    || x1 > mapx9 && x2 > mapx9
+		    || y1 < mapy0 && y2 < mapy0 || y1 > mapy9 && y2 > mapy9)
+		    continue;
+		int sd1 = OBJ_NO_NONE;
+		int sd2 = OBJ_NO_NONE;
+		int s1 = OBJ_NO_NONE;
+		int s2 = OBJ_NO_NONE;
+		// FIXME should flag negative sidedef numbers as errors
+		// FIXME should flag unused tag as errors
+		if ((sd1 = LineDefs[n].sidedef1) < 0 || sd1 >= NumSideDefs
+		    || (s1 = SideDefs[sd1].sector) < 0 || s1 >= NumSectors
+		    || (sd2 = LineDefs[n].sidedef2) >= NumSideDefs
+		    || sd2 >= 0 && ((s2 = SideDefs[sd2].sector) < 0
+				    || s2 >= NumSectors))
+		{
+		    new_colour = LIGHTRED;
+		}
+		else
+		{
+		    bool have_tag = false;
+		    bool have_type = false;
+		    if (Sectors[s1].tag != 0)
+			have_tag = true;
+		    if (Sectors[s1].special != 0)
+			have_type = true;
+		    if (sd2 >= 0)
+		    {
+			if (Sectors[s2].tag != 0)
+			    have_tag = true;
+			if (Sectors[s2].special != 0)
+			    have_type = true;
+		    }
+		    if (have_tag && have_type)
+			new_colour = SECTOR_TAGTYPE;
+		    else if (have_tag)
+			new_colour = SECTOR_TAG;
+		    else if (have_type)
+			new_colour = SECTOR_TYPE;
+		    else if (LineDefs[n].flags & 1)
+			new_colour = WHITE;
+		    else
+			new_colour = LIGHTGREY;
+		}
+		if (new_colour != current_colour)
+		    set_colour(current_colour = new_colour);
+		DrawMapLine(x1, y1, x2, y2);
+	    }
+	    break;
 	}
-	else
-	{
-	  bool have_tag  = false;
-	  bool have_type = false;
-	  if (Sectors[s1].tag != 0)
-	    have_tag = true;
-	  if (Sectors[s1].special != 0)
-	    have_type = true;
-	  if (sd2 >= 0)
-	  {
-	    if (Sectors[s2].tag != 0)
-	      have_tag = true;
-	    if (Sectors[s2].special != 0)
-	      have_type = true;
-	  }
-	  if (have_tag && have_type)
-	    new_colour = SECTOR_TAGTYPE;
-	  else if (have_tag)
-	    new_colour = SECTOR_TAG;
-	  else if (have_type)
-	    new_colour = SECTOR_TYPE;
-	  else if (LineDefs[n].flags & 1)
-	    new_colour = WHITE;
-	  else
-	    new_colour = LIGHTGREY;
-	}
-	if (new_colour != current_colour)
-	  set_colour (current_colour = new_colour);
-	DrawMapLine (x1, y1, x2, y2);
-      }
-      break;
     }
-  }
 }
 
 
 /*
  *	draw_things_squares - the obvious
  */
-static void draw_things_squares (edit_t *e)
+static void draw_things_squares(edit_t * e)
 {
-  // The radius of the largest thing.
-  int max_radius = get_max_thing_radius ();
+    // The radius of the largest thing.
+    int max_radius = get_max_thing_radius();
 
-  /* A thing is guaranteed to be totally off-screen
-     if its centre is more than <max_radius> units
-     beyond the edge of the screen. */
-  int mapx0      = MAPX (0)       - max_radius;
-  int mapx9      = MAPX (ScrMaxX) + max_radius;
-  int mapy0      = MAPY (ScrMaxY) - max_radius;
-  int mapy9      = MAPY (0)       + max_radius;
+    /* A thing is guaranteed to be totally off-screen
+       if its centre is more than <max_radius> units
+       beyond the edge of the screen. */
+    int mapx0 = MAPX(0) - max_radius;
+    int mapx9 = MAPX(ScrMaxX) + max_radius;
+    int mapy0 = MAPY(ScrMaxY) - max_radius;
+    int mapy9 = MAPY(0) + max_radius;
 
-  push_colour (THING_REM);
-  for (int n = 0; n < NumThings; n++)
-  {
-    int mapx = Things[n].xpos;
-    int mapy = Things[n].ypos;
-    int corner_x;
-    int corner_y;
-    if (mapx < mapx0 || mapx > mapx9 || mapy < mapy0 || mapy > mapy9)
-      continue;
-    int m = get_thing_radius (Things[n].type);
-    if (e->obj_type == OBJ_THINGS)
-      set_colour (get_thing_colour (Things[n].type));
+    push_colour(THING_REM);
+    for (int n = 0; n < NumThings; n++)
+    {
+	int mapx = Things[n].xpos;
+	int mapy = Things[n].ypos;
+	int corner_x;
+	int corner_y;
+	if (mapx < mapx0 || mapx > mapx9 || mapy < mapy0 || mapy > mapy9)
+	    continue;
+	int m = get_thing_radius(Things[n].type);
+	if (e->obj_type == OBJ_THINGS)
+	    set_colour(get_thing_colour(Things[n].type));
 #ifdef ROUND_THINGS
-    DrawMapLine (mapx - m, mapy,     mapx + m, mapy    );
-    DrawMapLine (mapx,     mapy - m, mapx,     mapy + m);
-    DrawMapCircle (mapx, mapy, m);
+	DrawMapLine(mapx - m, mapy, mapx + m, mapy);
+	DrawMapLine(mapx, mapy - m, mapx, mapy + m);
+	DrawMapCircle(mapx, mapy, m);
 #else
-    DrawMapLine (mapx - m, mapy - m, mapx + m, mapy - m);
-    DrawMapLine (mapx + m, mapy - m, mapx + m, mapy + m);
-    DrawMapLine (mapx + m, mapy + m, mapx - m, mapy + m);
-    DrawMapLine (mapx - m, mapy + m, mapx - m, mapy - m);
+	DrawMapLine(mapx - m, mapy - m, mapx + m, mapy - m);
+	DrawMapLine(mapx + m, mapy - m, mapx + m, mapy + m);
+	DrawMapLine(mapx + m, mapy + m, mapx - m, mapy + m);
+	DrawMapLine(mapx - m, mapy + m, mapx - m, mapy - m);
 #endif
-    {
-      size_t direction = angle_to_direction (Things[n].angle);
-      static const short xsign[] = {  1,  1,  0, -1, -1, -1,  0,  1,  0 };
-      static const short ysign[] = {  0,  1,  1,  1,  0, -1, -1, -1,  0 };
-      corner_x = m * xsign[direction];
-      corner_y = m * ysign[direction];
+	{
+	    size_t direction = angle_to_direction(Things[n].angle);
+	    static const short xsign[] = { 1, 1, 0, -1, -1, -1, 0, 1, 0 };
+	    static const short ysign[] = { 0, 1, 1, 1, 0, -1, -1, -1, 0 };
+	    corner_x = m * xsign[direction];
+	    corner_y = m * ysign[direction];
+	}
+	DrawMapLine(mapx, mapy, mapx + corner_x, mapy + corner_y);
     }
-    DrawMapLine (mapx, mapy, mapx + corner_x, mapy + corner_y);
-  }
-  pop_colour ();
+    pop_colour();
 }
 
 
@@ -618,16 +619,20 @@
 
 class Thing_npixels
 {
-  public :
-    Thing_npixels (i16 thing_no, unsigned long npixels, wad_ttype_t type)
-      : thing_no (thing_no), npixels (npixels), type (type) { }
-    bool operator< (const Thing_npixels& other) const
-      { if (this->npixels > other.npixels  // Decreasing npixels major
-	    || this->npixels == other.npixels  // Increasing type minor
-	       && this->type < other.type)
-	  return true;
+    public:
+	Thing_npixels(i16 thing_no, unsigned long npixels,
+		      wad_ttype_t type):thing_no(thing_no), npixels(npixels),
+	type(type)
+    {
+    }
+    bool operator<(const Thing_npixels & other) const
+    {
+	if (this->npixels > other.npixels	// Decreasing npixels major
+	    || this->npixels == other.npixels	// Increasing type minor
+	    && this->type < other.type)
+	    return true;
 	return false;
-      }
+    }
     i16 thing_no;
     unsigned long npixels;
     wad_ttype_t type;
@@ -636,28 +641,34 @@
 
 class Thing_list_by_size
 {
-  public :
-    Thing_list_by_size () { }
-    ~Thing_list_by_size () { }
-    const Thing_npixels& operator[] (int n) { return a[n]; }
-    void refresh ()
+    public: Thing_list_by_size()
+    {
+    }
+     ~Thing_list_by_size()
+    {
+    }
+    const Thing_npixels & operator[] (int n)
+    {
+	return a[n];
+    }
+    void refresh()
     {
-      a.clear ();
-      a.reserve (NumThings);
-      for (int n = 0; n < NumThings; n++)
-      {
-	Lump_loc loc;
-	const char *sprite_root = get_thing_sprite (Things[n].type);
-	if (sprite_root != NULL)
-	  wad_res.sprites.loc_by_root (sprite_root, loc);
-	else
-	  loc.len = 0;
-	a.push_back (Thing_npixels ((i16) n, loc.len, Things[n].type));
-      }
-      sort (a.begin (), a.end ());
+	a.clear();
+	a.reserve(NumThings);
+	for (int n = 0; n < NumThings; n++)
+	{
+	    Lump_loc loc;
+	    const char *sprite_root = get_thing_sprite(Things[n].type);
+	    if (sprite_root != NULL)
+		wad_res.sprites.loc_by_root(sprite_root, loc);
+	    else
+		loc.len = 0;
+	    a.push_back(Thing_npixels((i16) n, loc.len, Things[n].type));
+	}
+	sort(a.begin(), a.end());
     }
-  private :
-    std::vector <Thing_npixels> a;
+  private:
+    std::vector < Thing_npixels > a;
 };
 
 
@@ -671,126 +682,132 @@
 
 struct sprite_dim_t
 {
-  sprite_dim_t () { }
-  sprite_dim_t (int width, int height) : width (width), height (height) { }
-  unsigned short width;
-  unsigned short height;
+    sprite_dim_t()
+    {
+    }
+    sprite_dim_t(int width, int height):width(width), height(height)
+    {
+    }
+    unsigned short width;
+    unsigned short height;
 };
 
-typedef std::map <i16, sprite_dim_t> dim_map_t;
-static dim_map_t dim_map;  // FIXME there should be one for each game
+typedef std::map < i16, sprite_dim_t > dim_map_t;
+static dim_map_t dim_map;	// FIXME there should be one for each game
 
 
 /*
  *	draw_things_sprites - the obvious
  */
-static void draw_things_sprites (edit_t *e)
+static void draw_things_sprites(edit_t * e)
 {
 #ifdef NO_RENDER
-  static
+    static
 #endif
-  Sticker      sticker;
-  wad_ttype_t last_type = -1;  // Type of last thing displayed
-  dim_map_t::iterator dim = dim_map.end ();
-  bool set_dim = true;  // Init to avoid warning
-  const unsigned short max_width  = 1000;
-  const unsigned short max_height = 1000;
-  int mapx0 = 0;
-  int mapx9 = 0;
-  int mapy0 = 0;
-  int mapy9 = 0;
+    Sticker sticker;
+    wad_ttype_t last_type = -1;	// Type of last thing displayed
+    dim_map_t::iterator dim = dim_map.end();
+    bool set_dim = true;	// Init to avoid warning
+    const unsigned short max_width = 1000;
+    const unsigned short max_height = 1000;
+    int mapx0 = 0;
+    int mapx9 = 0;
+    int mapy0 = 0;
+    int mapy9 = 0;
 
-  if (things_types_prev != things_types)
-  {
-    list.refresh ();
-    things_types_prev = things_types;
-  }
+    if (things_types_prev != things_types)
+    {
+	list.refresh();
+	things_types_prev = things_types;
+    }
 
 #ifdef NO_RENDER
-  static double last_scale = 0;
-  if (last_scale != Scale)
-  {
-    Lump_loc loc;
-    wad_res.sprites.loc_by_root ("PLAY", loc);
-    Img img;
-    LoadPicture (img, "PLAYA0", loc, 0, 0);
-    Img img_scaled;
-    scale_img (img, Scale * sprite_scale / 100, img_scaled);
-    sprite.load (img_scaled, false);
-    last_scale = Scale;
-  }
+    static double last_scale = 0;
+    if (last_scale != Scale)
+    {
+	Lump_loc loc;
+	wad_res.sprites.loc_by_root("PLAY", loc);
+	Img img;
+	LoadPicture(img, "PLAYA0", loc, 0, 0);
+	Img img_scaled;
+	scale_img(img, Scale * sprite_scale / 100, img_scaled);
+	sprite.load(img_scaled, false);
+	last_scale = Scale;
+    }
 #endif
-  push_colour (CYAN);
-  for (int n = 0; n < NumThings; n++)
-  {
-    const Thing_npixels& t = list[n];
-
-    // Skip off-screen things
-    if (t.type != last_type)
+    push_colour(CYAN);
+    for (int n = 0; n < NumThings; n++)
     {
-      dim = dim_map.find (t.type);
-      if (dim == dim_map.end ())
-      {
-	set_dim = true;
-	mapx0 = MAPX (0)       - max_width / 2;
-	mapx9 = MAPX (ScrMaxX) + max_width / 2;
-	mapy0 = MAPY (ScrMaxY) - max_height / 2;
-	mapy9 = MAPY (0)       + max_height / 2;
-      }
-      else
-      {
-	mapx0 = MAPX (0)       - dim->second.width / 2;
-	mapx9 = MAPX (ScrMaxX) + dim->second.width / 2;
-	mapy0 = MAPY (ScrMaxY) - dim->second.height / 2;
-	mapy9 = MAPY (0)       + dim->second.height / 2;
-      }
-    }
-    int mapx = Things[t.thing_no].xpos;
-    int mapy = Things[t.thing_no].ypos;
-    if (mapx < mapx0 || mapx > mapx9 || mapy < mapy0 || mapy > mapy9)
-      continue;
+	const Thing_npixels & t = list[n];
+
+	// Skip off-screen things
+	if (t.type != last_type)
+	{
+	    dim = dim_map.find(t.type);
+	    if (dim == dim_map.end())
+	    {
+		set_dim = true;
+		mapx0 = MAPX(0) - max_width / 2;
+		mapx9 = MAPX(ScrMaxX) + max_width / 2;
+		mapy0 = MAPY(ScrMaxY) - max_height / 2;
+		mapy9 = MAPY(0) + max_height / 2;
+	    }
+	    else
+	    {
+		mapx0 = MAPX(0) - dim->second.width / 2;
+		mapx9 = MAPX(ScrMaxX) + dim->second.width / 2;
+		mapy0 = MAPY(ScrMaxY) - dim->second.height / 2;
+		mapy9 = MAPY(0) + dim->second.height / 2;
+	    }
+	}
+	int mapx = Things[t.thing_no].xpos;
+	int mapy = Things[t.thing_no].ypos;
+	if (mapx < mapx0 || mapx > mapx9 || mapy < mapy0 || mapy > mapy9)
+	    continue;
 
 #ifndef NO_RENDER
-    // If not the same as the last thing displayed, rasterize it
-    if (t.type != last_type)
-    {
-      last_type = t.type;
-
-      const char *sprite_root = get_thing_sprite (t.type);
-      if (sprite_root != NULL)
-      {
-	Lump_loc loc;
-	wad_res.sprites.loc_by_root (sprite_root, loc);
-	Img img_raw, img_scaled;
-	if (LoadPicture (img_raw, sprite_root, loc, 0, 0))
-	{
-	  sticker.clear ();  // We'll display the thing type instead
-	}
-	else
+	// If not the same as the last thing displayed, rasterize it
+	if (t.type != last_type)
 	{
-	  if (set_dim)
-	  {
-	    dim_map[t.type] = sprite_dim_t (img_raw.width(), img_raw.height());
-	    set_dim = false;
-	  }
-	  scale_img (img_raw, Scale * sprite_scale / 100, img_scaled);
-	  if (get_thing_flags (t.type) & THINGDEF_SPECTRAL)
-	     spectrify_img (img_scaled);
-	  sticker.load (img_scaled, false);
+	    last_type = t.type;
+
+	    const char *sprite_root = get_thing_sprite(t.type);
+	    if (sprite_root != NULL)
+	    {
+		Lump_loc loc;
+		wad_res.sprites.loc_by_root(sprite_root, loc);
+		Img img_raw, img_scaled;
+		if (LoadPicture(img_raw, sprite_root, loc, 0, 0))
+		{
+		    sticker.clear();	// We'll display the thing type instead
+		}
+		else
+		{
+		    if (set_dim)
+		    {
+			dim_map[t.type] =
+			    sprite_dim_t(img_raw.width(), img_raw.height());
+			set_dim = false;
+		    }
+		    scale_img(img_raw, Scale * sprite_scale / 100,
+			      img_scaled);
+		    if (get_thing_flags(t.type) & THINGDEF_SPECTRAL)
+			spectrify_img(img_scaled);
+		    sticker.load(img_scaled, false);
+		}
+	    }
+	    else
+		sticker.clear();	// We'll display the thing type instead
 	}
-      }
-      else
-	sticker.clear ();  // We'll display the thing type instead
+#endif
+
+	// Display it
+	if (sticker.is_clear())
+	    draw_vint(t.type, SCREENX(mapx), SCREENY(mapy), Scale);
+	else
+	    sticker.draw(drw, 'c', SCREENX(mapx), SCREENY(mapy));
     }
-#endif
-    
-    // Display it
-    if (sticker.is_clear ())
-      draw_vint (t.type, SCREENX (mapx), SCREENY (mapy), Scale);
-    else
-      sticker.draw (drw, 'c', SCREENX (mapx), SCREENY (mapy));
-  }
-  pop_colour ();
+    pop_colour();
 }
 
 
@@ -799,24 +816,23 @@
  *
  *	FIXME too slow.
  */
-static void draw_obj_no (int x, int y, int obj_no, acolour_t c)
+static void draw_obj_no(int x, int y, int obj_no, acolour_t c)
 {
-  push_colour (BLACK);
+    push_colour(BLACK);
 #if 1
-  DrawScreenText (x - 2, y,     "%d", obj_no);
-  DrawScreenText (x - 1, y,     "%d", obj_no);
-  DrawScreenText (x + 1, y,     "%d", obj_no);
-  DrawScreenText (x + 2, y,     "%d", obj_no);
-  DrawScreenText (x,     y + 1, "%d", obj_no);
-  DrawScreenText (x,     y - 1, "%d", obj_no);
+    DrawScreenText(x - 2, y, "%d", obj_no);
+    DrawScreenText(x - 1, y, "%d", obj_no);
+    DrawScreenText(x + 1, y, "%d", obj_no);
+    DrawScreenText(x + 2, y, "%d", obj_no);
+    DrawScreenText(x, y + 1, "%d", obj_no);
+    DrawScreenText(x, y - 1, "%d", obj_no);
 #else
-  DrawScreenText (x + 1, y + 1, "%d", obj_no);
-  DrawScreenText (x + 1, y - 1, "%d", obj_no);
-  DrawScreenText (x - 1, y + 1, "%d", obj_no);
-  DrawScreenText (x - 1, y - 1, "%d", obj_no);
+    DrawScreenText(x + 1, y + 1, "%d", obj_no);
+    DrawScreenText(x + 1, y - 1, "%d", obj_no);
+    DrawScreenText(x - 1, y + 1, "%d", obj_no);
+    DrawScreenText(x - 1, y - 1, "%d", obj_no);
 #endif
-  set_colour (c);
-  DrawScreenText (x,     y,     "%d", obj_no);
-  pop_colour ();
+    set_colour(c);
+    DrawScreenText(x, y, "%d", obj_no);
+    pop_colour();
 }
-
--- a/src/drawmap.h	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/drawmap.h	Sat Sep 24 14:16:04 2011 +0300
@@ -10,10 +10,10 @@
 #include "_edit.h"
 
 
-int vertex_radius (double scale);
+int vertex_radius(double scale);
 
-void draw_map (edit_t *e);
-void draw_infobar (const edit_t *e);
+void draw_map(edit_t * e);
+void draw_infobar(const edit_t * e);
 
 
 #endif
--- a/src/edisplay.cc	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/edisplay.cc	Sat Sep 24 14:16:04 2011 +0300
@@ -60,7 +60,7 @@
 #include "gfx.h"
 #include "highlt.h"
 #include "infobar.h"
-#include "levels.h"	// Level
+#include "levels.h"		// Level
 #include "menu.h"
 #include "menubar.h"
 #include "modpopup.h"
@@ -71,143 +71,136 @@
 #include "wadfile.h"
 
 
-edisplay_c::edisplay_c (edit_t *e)
+edisplay_c::edisplay_c(edit_t * e)
 {
-  this->e = e;
-  pointer_scnx = 0;
-  pointer_scny = 0;
-  refresh_needed = 1;
-  highlight = new highlight_c;
-  objinfo   = new objinfo_c;
-  infobar   = new infobar_c;
+    this->e = e;
+    pointer_scnx = 0;
+    pointer_scny = 0;
+    refresh_needed = 1;
+    highlight = new highlight_c;
+    objinfo = new objinfo_c;
+    infobar = new infobar_c;
 }
 
 
-edisplay_c::~edisplay_c ()
+edisplay_c::~edisplay_c()
 {
-  delete highlight;
-  delete objinfo;
+    delete highlight;
+    delete objinfo;
 }
 
 
 // FIXME this should not be a separate method
-void edisplay_c::highlight_object (Objid& obj)
+void edisplay_c::highlight_object(Objid & obj)
 {
-  highlight->set (obj);
-  objinfo->set (obj.type, obj.num);
+    highlight->set(obj);
+    objinfo->set(obj.type, obj.num);
 }
 
 
 // FIXME this should not be a separate method
-void edisplay_c::forget_highlight ()
+void edisplay_c::forget_highlight()
 {
-  highlight->unset ();
-  /* I don't unset objinfo because, as it can't undraw
-     itself, it would lead to redrawing everything from
-     scratch everytime an object passes out of focus. */
-  //objinfo->unset ();
+    highlight->unset();
+    /* I don't unset objinfo because, as it can't undraw
+       itself, it would lead to redrawing everything from
+       scratch everytime an object passes out of focus. */
+    //objinfo->unset ();
 }
 
 
-void edisplay_c::need_refresh ()
+void edisplay_c::need_refresh()
 {
-  refresh_needed = 1;
+    refresh_needed = 1;
 }
 
 
-void edisplay_c::refresh ()
+void edisplay_c::refresh()
 {
-  int redraw_from_scratch;
+    int redraw_from_scratch;
 
-  // The poor hacker's geometry manager (FIXME: this needs work!)
-  infobar->set_x1 (ScrMaxX);
-  infobar->set_y1 (ScrMaxY);
-  infobar->set_x0 (0);
-  infobar->set_y0 (ScrMaxY - (infobar->req_height () - 1));
-  objinfo->set_y1 (e->infobar_shown ? infobar->get_y0 () - 1 : ScrMaxY);
+    // The poor hacker's geometry manager (FIXME: this needs work!)
+    infobar->set_x1(ScrMaxX);
+    infobar->set_y1(ScrMaxY);
+    infobar->set_x0(0);
+    infobar->set_y0(ScrMaxY - (infobar->req_height() - 1));
+    objinfo->set_y1(e->infobar_shown ? infobar->get_y0() - 1 : ScrMaxY);
 
-  /* Extract the interesting data from the edit_c object
-     and feed it to the widgets. */
-  infobar->set_visible          (e->infobar_shown);
-  infobar->set_file_name        (Level
-				   ? Level->wadfile->pathname ()
-				   : 0);
-  infobar->set_level_name       (Level
-				   ? (const char *) Level->dir.name
-				   : 0);
-  infobar->set_obj_type         (e->obj_type);
-  infobar->set_changes          (MadeMapChanges ? 2 : (MadeChanges ? 1 : 0));
-  infobar->set_grid_snap        (e->grid_snap);
-  infobar->set_grid_step_locked (e->grid_step_locked);
-  infobar->set_scale            (Scale);
-  infobar->set_grid_step        (e->grid_step);
-  if (e->pointer_in_window)
-    infobar->set_pointer (e->pointer_x, e->pointer_y);
-  else
-    infobar->unset_pointer ();
+    /* Extract the interesting data from the edit_c object
+       and feed it to the widgets. */
+    infobar->set_visible(e->infobar_shown);
+    infobar->set_file_name(Level ? Level->wadfile->pathname() : 0);
+    infobar->set_level_name(Level ? (const char *) Level->dir.name : 0);
+    infobar->set_obj_type(e->obj_type);
+    infobar->set_changes(MadeMapChanges ? 2 : (MadeChanges ? 1 : 0));
+    infobar->set_grid_snap(e->grid_snap);
+    infobar->set_grid_step_locked(e->grid_step_locked);
+    infobar->set_scale(Scale);
+    infobar->set_grid_step(e->grid_step);
+    if (e->pointer_in_window)
+	infobar->set_pointer(e->pointer_x, e->pointer_y);
+    else
+	infobar->unset_pointer();
 
 
-  redraw_from_scratch =
-    refresh_needed
-    || e->selbox->need_to_clear   ()
-    || e->spot->need_to_clear     ()
-    || highlight->need_to_clear   ()
-    || objinfo->need_to_clear     ()
-    || infobar->need_to_clear     ()
-    || e->menubar->need_to_clear  ()
-    || e->modpopup->need_to_clear ();
-   
-  /* If we can update the display in an incremental fashion
-     (not from scratch), do it by telling all widgets, from
-     the top to the bottom, to undraw themselves if necessary. */
-  if (! redraw_from_scratch)
-  {
-    e->modpopup->undraw ();
-    e->menubar->undraw  ();
-    infobar->undraw     ();
-    objinfo->undraw     ();
-    highlight->undraw   ();
-    e->spot->undraw     ();
-    e->selbox->undraw   ();
-  }
+    redraw_from_scratch =
+	refresh_needed
+	|| e->selbox->need_to_clear()
+	|| e->spot->need_to_clear()
+	|| highlight->need_to_clear()
+	|| objinfo->need_to_clear()
+	|| infobar->need_to_clear()
+	|| e->menubar->need_to_clear() || e->modpopup->need_to_clear();
+
+    /* If we can update the display in an incremental fashion
+       (not from scratch), do it by telling all widgets, from
+       the top to the bottom, to undraw themselves if necessary. */
+    if (!redraw_from_scratch)
+    {
+	e->modpopup->undraw();
+	e->menubar->undraw();
+	infobar->undraw();
+	objinfo->undraw();
+	highlight->undraw();
+	e->spot->undraw();
+	e->selbox->undraw();
+    }
 
-  /* If a complete refresh is required, call the clear()
-     method for all widgets to make them aware that they're
-     not visible anymore. */
-  else
-  {
-    e->selbox->clear   ();
-    e->spot->clear     ();
-    highlight->clear   ();
-    objinfo->clear     ();
-    infobar->clear     ();
-    e->menubar->clear  ();
-    e->modpopup->clear ();
+    /* If a complete refresh is required, call the clear()
+       method for all widgets to make them aware that they're
+       not visible anymore. */
+    else
+    {
+	e->selbox->clear();
+	e->spot->clear();
+	highlight->clear();
+	objinfo->clear();
+	infobar->clear();
+	e->menubar->clear();
+	e->modpopup->clear();
 
-    // A piece of ad-hockery
-    objinfo->unset ();
+	// A piece of ad-hockery
+	objinfo->unset();
 
-    // As we said, "from scratch".
-    ClearScreen ();
-    draw_map (e);     // FIXME should be widgetized
-    // draw_menubar ();  // FIXME should be widgetized
-    HighlightSelection (e->obj_type, e->Selected); // FIXME should be widgetized
-    refresh_needed = 0;
-  }
+	// As we said, "from scratch".
+	ClearScreen();
+	draw_map(e);		// FIXME should be widgetized
+	// draw_menubar ();  // FIXME should be widgetized
+	HighlightSelection(e->obj_type, e->Selected);	// FIXME should be widgetized
+	refresh_needed = 0;
+    }
 
-  /* Tell all widgets from to bottom to the top
-     to draw themselves if necessary. */
-  e->selbox->draw   ();
-  e->spot->draw     ();
-  highlight->draw   ();
-  if (e->objinfo_shown)
-    objinfo->draw     ();
-  infobar->draw     ();
-  e->menubar->draw  ();
-  e->modpopup->draw ();
+    /* Tell all widgets from to bottom to the top
+       to draw themselves if necessary. */
+    e->selbox->draw();
+    e->spot->draw();
+    highlight->draw();
+    if (e->objinfo_shown)
+	objinfo->draw();
+    infobar->draw();
+    e->menubar->draw();
+    e->modpopup->draw();
 
-  // Refresh the physical display
-  update_display ();
+    // Refresh the physical display
+    update_display();
 }
-
-
--- a/src/edisplay.h	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/edisplay.h	Sat Sep 24 14:16:04 2011 +0300
@@ -10,26 +10,21 @@
 
 
 class edisplay_c
-   {
-   public :
-      edisplay_c (edit_t *e);
-      ~edisplay_c ();
-      void refresh ();
-      void need_refresh ();
-      void highlight_object (Objid& obj);
-      void forget_highlight ();
+{
+    public:edisplay_c(edit_t * e);
+    ~edisplay_c();
+    void refresh();
+    void need_refresh();
+    void highlight_object(Objid & obj);
+    void forget_highlight();
 
-   private :
-      edit_t *e;		/* Parent editing window */
-      int requested_highlight;	/* No. of object that should be highlighted */
-      int actual_highlight;	/* No. of object that really is highlighted */
-      int pointer_scnx;		/* Physical position of the pointer */
-      int pointer_scny;
-      int refresh_needed;	/* If true, the display needs to be refreshed */
-      highlight_c *highlight;
-      objinfo_c *objinfo;
-      infobar_c *infobar;
-   };
-
-
-
+      private: edit_t * e;	/* Parent editing window */
+    int requested_highlight;	/* No. of object that should be highlighted */
+    int actual_highlight;	/* No. of object that really is highlighted */
+    int pointer_scnx;		/* Physical position of the pointer */
+    int pointer_scny;
+    int refresh_needed;		/* If true, the display needs to be refreshed */
+    highlight_c *highlight;
+    objinfo_c *objinfo;
+    infobar_c *infobar;
+};
--- a/src/editgrid.cc	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/editgrid.cc	Sat Sep 24 14:16:04 2011 +0300
@@ -32,15 +32,10 @@
 #include "editgrid.h"
 
 
-void edit_grid_adapt (edit_t *e)
+void edit_grid_adapt(edit_t * e)
 {
-  if (! e->grid_step_locked)
-    for (e->grid_step = e->grid_step_max;
-	 e->grid_step * Scale / 2 >= grid_pixels_min;
-	 e->grid_step /= 2)
-      ;
+    if (!e->grid_step_locked)
+	for (e->grid_step = e->grid_step_max;
+	     e->grid_step * Scale / 2 >= grid_pixels_min; e->grid_step /= 2)
+	    ;
 }
-
-
-
-
--- a/src/editgrid.h	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/editgrid.h	Sat Sep 24 14:16:04 2011 +0300
@@ -27,7 +27,7 @@
 */
 
 
-void edit_grid_adapt (edit_t *e);
+void edit_grid_adapt(edit_t * e);
 
 
 /*
@@ -35,14 +35,14 @@
  *	Return <mapx> snapped to grid
  *	(or unchanged is snap_to_grid is off)
  */
-inline int edit_mapx_snapped (const edit_t *e, int mapx)
+inline int edit_mapx_snapped(const edit_t * e, int mapx)
 {
-if (! e->grid_snap || e->grid_step == 0)
-   return mapx;
-if (mapx >= 0)
-   return e->grid_step * ((mapx + e->grid_step / 2) / e->grid_step);
-else
-   return e->grid_step * ((mapx - e->grid_step / 2) / e->grid_step);
+    if (!e->grid_snap || e->grid_step == 0)
+	return mapx;
+    if (mapx >= 0)
+	return e->grid_step * ((mapx + e->grid_step / 2) / e->grid_step);
+    else
+	return e->grid_step * ((mapx - e->grid_step / 2) / e->grid_step);
 }
 
 
@@ -51,24 +51,12 @@
  *	Return <mapy> snapped to grid
  *	(or unchanged is snap_to_grid is off)
  */
-inline int edit_mapy_snapped (const edit_t *e, int mapy)
+inline int edit_mapy_snapped(const edit_t * e, int mapy)
 {
-if (! e->grid_snap || e->grid_step == 0)
-   return mapy;
-if (mapy >= 0)
-   return e->grid_step * ((mapy + e->grid_step / 2) / e->grid_step);
-else
-   return e->grid_step * ((mapy - e->grid_step / 2) / e->grid_step);
+    if (!e->grid_snap || e->grid_step == 0)
+	return mapy;
+    if (mapy >= 0)
+	return e->grid_step * ((mapy + e->grid_step / 2) / e->grid_step);
+    else
+	return e->grid_step * ((mapy - e->grid_step / 2) / e->grid_step);
 }
-
-
-/* The old method for snapping to grid.
-   Required that grid_step be a power of 2. */
-#if 0
-(MAPX (is.x) + e.grid_step / 2) & ~(e.grid_step - 1),
-(MAPY (is.y) + e.grid_step / 2) & ~(e.grid_step - 1));
-MoveObjectsToCoords (e.obj_type, 0,
-e.pointer_x, e.pointer_y, e.grid_snap ? e.grid_step : 0);
-#endif
-
-
--- a/src/editlev.cc	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/editlev.cc	Sat Sep 24 14:16:04 2011 +0300
@@ -42,8 +42,8 @@
 #include "wadfile.h"
 
 
-static void WriteYadexLog (const char *file, const char *level,
- time_t *t0, time_t *t1);
+static void WriteYadexLog(const char *file, const char *level,
+			  time_t * t0, time_t * t1);
 
 
 /*
@@ -71,74 +71,74 @@
  *	  - if the <name_given> is invalid, <error_invalid>,
  *	  - if several were found, <error_non_unique>.
  */
-char *find_level (const char *name_given)
+char *find_level(const char *name_given)
 {
 // Is it a shorthand name ? ("1", "23", ...)
-if (al_sisnum (name_given)
-    && (atoi (name_given) <= 99
-      || atoi (name_given) <= 999 && yg_level_name == YGLN_E1M10))
-   {
-   int n = atoi (name_given);
-   char *name1 = (char *) malloc (7);
-   char *name2 = (char *) malloc (6);
-   if (n > 99)
-      sprintf (name1, "E%dM%02d", n / 100, n % 100);
-   else
-      sprintf (name1, "E%dM%d", n / 10, n % 10);
-   sprintf (name2, "MAP%02d", n);
-   int match1 = FindMasterDir (MasterDir, name1) != NULL;
-   int match2 = FindMasterDir (MasterDir, name2) != NULL;
-   if (match1 && ! match2)	// Found only ExMy
-      {
-      free (name2);
-      return name1;
-      }
-   else if (match2 && ! match1)	// Found only MAPxy
-      {
-      free (name1);
-      return name2;
-      }
-   else if (match1 && match2)	// Found both
-      {
-      free (name1);
-      free (name2);
-      return error_non_unique;
-      }
-   else				// Found none
-      {
-      free (name1);
-      free (name2);
-      return error_none;
-      }
-   }
+    if (al_sisnum(name_given)
+	&& (atoi(name_given) <= 99
+	    || atoi(name_given) <= 999 && yg_level_name == YGLN_E1M10))
+    {
+	int n = atoi(name_given);
+	char *name1 = (char *) malloc(7);
+	char *name2 = (char *) malloc(6);
+	if (n > 99)
+	    sprintf(name1, "E%dM%02d", n / 100, n % 100);
+	else
+	    sprintf(name1, "E%dM%d", n / 10, n % 10);
+	sprintf(name2, "MAP%02d", n);
+	int match1 = FindMasterDir(MasterDir, name1) != NULL;
+	int match2 = FindMasterDir(MasterDir, name2) != NULL;
+	if (match1 && !match2)	// Found only ExMy
+	{
+	    free(name2);
+	    return name1;
+	}
+	else if (match2 && !match1)	// Found only MAPxy
+	{
+	    free(name1);
+	    return name2;
+	}
+	else if (match1 && match2)	// Found both
+	{
+	    free(name1);
+	    free(name2);
+	    return error_non_unique;
+	}
+	else			// Found none
+	{
+	    free(name1);
+	    free(name2);
+	    return error_none;
+	}
+    }
 
 #if 1
 // Else look for <name_given>
-if (FindMasterDir (MasterDir, name_given))
-   return al_sdup (name_given);
-else
-   {
-   if (levelname2levelno (name_given))
-      return NULL;
-   else
-      return error_invalid;
-   }
+    if (FindMasterDir(MasterDir, name_given))
+	return al_sdup(name_given);
+    else
+    {
+	if (levelname2levelno(name_given))
+	    return NULL;
+	else
+	    return error_invalid;
+    }
 #else
 // If <name_given> is "[Ee]n[Mm]m" or "[Mm][Aa][Pp]nm", look for that
-if (levelname2levelno (name_given))
-   {
-   char *canonical_name = strdup (name_given);
-   for (char *p = canonical_name; *p; p++)
-      *p = toupper (*p);  // But shouldn't FindMasterDir() be case-insensitive ?
-   if (FindMasterDir (MasterDir, canonical_name))
-      return canonical_name;
-   else
-      {
-      free (canonical_name);
-      return NULL;
-      }
-   }
-return error_invalid;
+    if (levelname2levelno(name_given))
+    {
+	char *canonical_name = strdup(name_given);
+	for (char *p = canonical_name; *p; p++)
+	    *p = toupper(*p);	// But shouldn't FindMasterDir() be case-insensitive ?
+	if (FindMasterDir(MasterDir, canonical_name))
+	    return canonical_name;
+	else
+	{
+	    free(canonical_name);
+	    return NULL;
+	}
+    }
+    return error_invalid;
 #endif
 }
 
@@ -147,107 +147,108 @@
    the driving program
 */
 
-void EditLevel (const char *levelname, bool newlevel)
+void EditLevel(const char *levelname, bool newlevel)
 {
-ReadWTextureNames ();
-ReadFTextureNames ();
-patch_dir.refresh (MasterDir);
-if (InitGfx ())
-   return;
+    ReadWTextureNames();
+    ReadFTextureNames();
+    patch_dir.refresh(MasterDir);
+    if (InitGfx())
+	return;
 /* Call init_input_status() as shortly as possible after the creation
    of the window to minimize the risk of calling get_input_status(),
    get_key(), have_key(), etc. with <is> still uninitialized. */
-init_input_status ();
-init_event ();
-if (newlevel && ! levelname)  // "create"
-   {
-   EmptyLevelData (levelname);
-   MapMinX = -2000;
-   MapMinY = -2000;
-   MapMaxX = 2000;
-   MapMaxY = 2000;
-   Level = 0;
-   }
-else if (newlevel && levelname)  // "create <level_name>"
-   {
-   printf ("Sorry, \"create <level_name>\" is not implemented."
-	 " Try \"create\" without argument.\n");
-   TermGfx ();
-   return;
-   }
-else  // "edit <level_name>" or "edit"
-   {
+    init_input_status();
+    init_event();
+    if (newlevel && !levelname)	// "create"
+    {
+	EmptyLevelData(levelname);
+	MapMinX = -2000;
+	MapMinY = -2000;
+	MapMaxX = 2000;
+	MapMaxY = 2000;
+	Level = 0;
+    }
+    else if (newlevel && levelname)	// "create <level_name>"
+    {
+	printf("Sorry, \"create <level_name>\" is not implemented."
+	       " Try \"create\" without argument.\n");
+	TermGfx();
+	return;
+    }
+    else			// "edit <level_name>" or "edit"
+    {
 #if 0
-   if (levelname == 0 || ! levelname2levelno (levelname)
-    || ! FindMasterDir (MasterDir, levelname))
-      levelname = SelectLevel (atoi (levelname)); /* returns "" on Esc */
-   if (levelname2levelno (levelname))
-      {
+	if (levelname == 0 || !levelname2levelno(levelname)
+	    || !FindMasterDir(MasterDir, levelname))
+	    levelname = SelectLevel(atoi(levelname));	/* returns "" on Esc */
+	if (levelname2levelno(levelname))
+	{
 #endif
-      ClearScreen ();
-      if (ReadLevelData (levelname))
-	 {
-	 goto done;  // Failure!
-	 }
+	    ClearScreen();
+	    if (ReadLevelData(levelname))
+	    {
+		goto done;	// Failure!
+	    }
 #if 0
-      }
+	}
 #endif
-   }
-LogMessage (": Editing %s...\n", levelname ? levelname : "new level");
+    }
+    LogMessage(": Editing %s...\n", levelname ? levelname : "new level");
 
 // Set the name of the window
-{
+    {
 #define BUFSZ 100
-char buf[BUFSZ + 1];
+	char buf[BUFSZ + 1];
 
 #ifdef OLD_TITLE
-al_scps (buf, "Yadex - ", BUFSZ);
-if (Level && Level->wadfile)
-   al_saps (buf, Level->wadfile->filename, BUFSZ);
-else
-   al_saps (buf, "New level", BUFSZ);
-if (Level)
-   {
-   al_saps (buf, " - ",           BUFSZ);
-   al_saps (buf, Level->dir.name, BUFSZ);
-   }
-else if (levelname)
-   {
-   al_saps (buf, " - ",     BUFSZ);
-   al_saps (buf, levelname, BUFSZ);
-   }
+	al_scps(buf, "Yadex - ", BUFSZ);
+	if (Level && Level->wadfile)
+	    al_saps(buf, Level->wadfile->filename, BUFSZ);
+	else
+	    al_saps(buf, "New level", BUFSZ);
+	if (Level)
+	{
+	    al_saps(buf, " - ", BUFSZ);
+	    al_saps(buf, Level->dir.name, BUFSZ);
+	}
+	else if (levelname)
+	{
+	    al_saps(buf, " - ", BUFSZ);
+	    al_saps(buf, levelname, BUFSZ);
+	}
 #else
-al_scps (buf, "Yadex: ", BUFSZ);
-al_saps (buf, (levelname) ? levelname : "(null)", BUFSZ);
+	al_scps(buf, "Yadex: ", BUFSZ);
+	al_saps(buf, (levelname) ? levelname : "(null)", BUFSZ);
 #endif
-XStoreName (dpy, win, buf);
+	XStoreName(dpy, win, buf);
 #undef BUFSZ
-}
+    }
 
-{
-time_t t0, t1;
-time (&t0);
-EditorLoop (levelname);
-time (&t1);
-LogMessage (": Finished editing %s...\n", levelname ? levelname : "new level");
-if (Level && Level->wadfile)
-   {
-   const char *const file_name =
-      Level->wadfile ? Level->wadfile->pathname () : "(New level)";
-   WriteYadexLog (file_name, levelname, &t0, &t1);
-   }
-}
-done :
-TermGfx ();
-if (! Registered)
-   printf ("Please register the game"
-      " if you want to be able to save your changes.\n");
+    {
+	time_t t0, t1;
+	time(&t0);
+	EditorLoop(levelname);
+	time(&t1);
+	LogMessage(": Finished editing %s...\n",
+		   levelname ? levelname : "new level");
+	if (Level && Level->wadfile)
+	{
+	    const char *const file_name =
+		Level->wadfile ? Level->wadfile->pathname() : "(New level)";
+	    WriteYadexLog(file_name, levelname, &t0, &t1);
+	}
+    }
+  done:
+    TermGfx();
+    if (!Registered)
+	printf("Please register the game"
+	       " if you want to be able to save your changes.\n");
 
-ForgetLevelData ();
+    ForgetLevelData();
 /* forget the level pointer */
-Level = 0;
-ForgetWTextureNames ();
-ForgetFTextureNames ();
+    Level = 0;
+    ForgetWTextureNames();
+    ForgetFTextureNames();
 }
 
 
@@ -255,30 +256,29 @@
  *	WriteYadexLog - Keep track of time spent editing that wad file
  *	FIXME should be in a separate module
  */
-static void WriteYadexLog (const char *file, const char *level, time_t *t0, time_t *t1)
+static void WriteYadexLog(const char *file, const char *level, time_t * t0,
+			  time_t * t1)
 {
-al_fspec_t logname;
-al_fdrv_t  drive;
-al_fpath_t path;
-al_fbase_t base;
+    al_fspec_t logname;
+    al_fdrv_t drive;
+    al_fpath_t path;
+    al_fbase_t base;
 
-al_fana (file, drive, path, base, 0);
-sprintf (logname, "%s%s%s.yl", drive, path, base);
+    al_fana(file, drive, path, base, 0);
+    sprintf(logname, "%s%s%s.yl", drive, path, base);
 
 /* if log file does not already exist, do _not_ create it */
-if (al_fnature (logname) == 1)
-   {
-   FILE *logfd;
-   logfd = fopen (logname, "a");
-   if (logfd)
-      {
-      struct tm *tm = localtime (t0);
-      fprintf (logfd, "%04d%02d%02d\tedit\t%s\t%ld\n",
-       tm->tm_year+1900, tm->tm_mon+1, tm->tm_mday, level, (long)(*t1-*t0)/60);
-      fclose (logfd);
-      }
-   }
+    if (al_fnature(logname) == 1)
+    {
+	FILE *logfd;
+	logfd = fopen(logname, "a");
+	if (logfd)
+	{
+	    struct tm *tm = localtime(t0);
+	    fprintf(logfd, "%04d%02d%02d\tedit\t%s\t%ld\n",
+		    tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, level,
+		    (long) (*t1 - *t0) / 60);
+	    fclose(logfd);
+	}
+    }
 }
-
-
-
--- a/src/editlev.h	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/editlev.h	Sat Sep 24 14:16:04 2011 +0300
@@ -4,6 +4,5 @@
  */
 
 
-char *find_level (const char *name_given);
-void EditLevel (const char *, bool);
-
+char *find_level(const char *name_given);
+void EditLevel(const char *, bool);
--- a/src/editloop.cc	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/editloop.cc	Sat Sep 24 14:16:04 2011 +0300
@@ -72,13 +72,13 @@
 #include "r_render.h"
 
 
-static int zoom_fit (edit_t&);
+static int zoom_fit(edit_t &);
 extern bool InfoShown;		/* should we display the info bar? */
 static int menubar_out_y1;	/* FIXME */
 
 
 /* prototypes of private functions */
-static int SortLevels (const void *item1, const void *item2);
+static int SortLevels(const void *item1, const void *item2);
 
 /*
  *	SelectLevel
@@ -96,41 +96,43 @@
  *	because "e" now requires an argument and tends to deal
  *	with ambiguous level names (like "12") itself.
  */
-const char *SelectLevel (int levelno)
+const char *SelectLevel(int levelno)
 {
-MDirPtr dir;
-static char name[WAD_NAME + 1]; /* AYM it was [7] previously */
-char **levels = 0;
-int n = 0;           /* number of levels in the dir. that match */
+    MDirPtr dir;
+    static char name[WAD_NAME + 1];	/* AYM it was [7] previously */
+    char **levels = 0;
+    int n = 0;			/* number of levels in the dir. that match */
 
-get_levels_that_match:
-for (dir = MasterDir; dir; dir = dir->next)
-   {
-   if (levelname2levelno (dir->dir.name) > 0
-    && (levelno==0 || levelname2levelno (dir->dir.name) % 1000 == levelno))
-      {
-      if (n == 0)
-	 levels = (char **) GetMemory (sizeof (char *));
-      else
-	 levels = (char **) ResizeMemory (levels, (n + 1) * sizeof (char *));
-      levels[n] = dir->dir.name;
-      n++;
-      }
-   }
-if (n == 0 && levelno != 0)  /* In case no level matched levelno */
-   {
-   levelno = 0;               /* List ALL levels instead */
-   goto get_levels_that_match;
-   }
+  get_levels_that_match:
+    for (dir = MasterDir; dir; dir = dir->next)
+    {
+	if (levelname2levelno(dir->dir.name) > 0
+	    && (levelno == 0
+		|| levelname2levelno(dir->dir.name) % 1000 == levelno))
+	{
+	    if (n == 0)
+		levels = (char **) GetMemory(sizeof(char *));
+	    else
+		levels =
+		    (char **) ResizeMemory(levels, (n + 1) * sizeof(char *));
+	    levels[n] = dir->dir.name;
+	    n++;
+	}
+    }
+    if (n == 0 && levelno != 0)	/* In case no level matched levelno */
+    {
+	levelno = 0;		/* List ALL levels instead */
+	goto get_levels_that_match;
+    }
 /* So that InputNameFromList doesn't fail if you
    have both EnMn's and MAPnn's in the master dir. */
-qsort (levels, n, sizeof (char *), SortLevels);
-al_scps (name, levels[0], sizeof name - 1);
-if (n == 1)
-   return name;
-InputNameFromList (-1, -1, "Level name :", n, levels, name);
-FreeMemory (levels);
-return name;
+    qsort(levels, n, sizeof(char *), SortLevels);
+    al_scps(name, levels[0], sizeof name - 1);
+    if (n == 1)
+	return name;
+    InputNameFromList(-1, -1, "Level name :", n, levels, name);
+    FreeMemory(levels);
+    return name;
 }
 
 
@@ -138,317 +140,350 @@
    compare 2 level names (for sorting)
 */
 
-static int SortLevels (const void *item1, const void *item2)
+static int SortLevels(const void *item1, const void *item2)
 {
 /* FIXME should probably use y_stricmp() instead */
-return strcmp (*((const char * const *) item1),
-               *((const char * const *) item2));
+    return strcmp(*((const char *const *) item1),
+		  *((const char *const *) item2));
 }
 
 
 // A table of the modes in the editor.
 typedef struct
-   {
-   i8 obj_type;		// Corresponding object type
-   i8 item_no;		// # of item to tick in the "View" menu
-   i8 menu_no;		// # of flavour of the "Misc op." menu
-   } editmode_t;
+{
+    i8 obj_type;		// Corresponding object type
+    i8 item_no;			// # of item to tick in the "View" menu
+    i8 menu_no;			// # of flavour of the "Misc op." menu
+} editmode_t;
 
 const int NB_MODES = 4;
 
-static const editmode_t modes[NB_MODES] =
-   {
-   { OBJ_THINGS,   0, MBM_MISC_T },
-   { OBJ_LINEDEFS, 1, MBM_MISC_L },
-   { OBJ_VERTICES, 2, MBM_MISC_V },
-   { OBJ_SECTORS,  3, MBM_MISC_S },
-   };
+static const editmode_t modes[NB_MODES] = {
+    {OBJ_THINGS, 0, MBM_MISC_T},
+    {OBJ_LINEDEFS, 1, MBM_MISC_L},
+    {OBJ_VERTICES, 2, MBM_MISC_V},
+    {OBJ_SECTORS, 3, MBM_MISC_S},
+};
 
 
 /*
  *	obj_type_to_mode_no
  *	Return the # of the mode that has this <obj_type>
  */
-static int obj_type_to_mode_no (int obj_type)
+static int obj_type_to_mode_no(int obj_type)
 {
-int n;
-for (n = 0; n < NB_MODES; n++)
-   if (modes[n].obj_type == obj_type)
-      break;
-if (n == NB_MODES)
-   fatal_error ("no mode for obj_type %d", obj_type);
-return n;
+    int n;
+    for (n = 0; n < NB_MODES; n++)
+	if (modes[n].obj_type == obj_type)
+	    break;
+    if (n == NB_MODES)
+	fatal_error("no mode for obj_type %d", obj_type);
+    return n;
 }
 
 
 // Used by the View menu
-bool mode_th (micbarg_t p) { return ((edit_t *) p)->obj_type == OBJ_THINGS;   }
-bool mode_l  (micbarg_t p) { return ((edit_t *) p)->obj_type == OBJ_LINEDEFS; }
-bool mode_v  (micbarg_t p) { return ((edit_t *) p)->obj_type == OBJ_VERTICES; }
-bool mode_s  (micbarg_t p) { return ((edit_t *) p)->obj_type == OBJ_SECTORS;  }
+bool mode_th(micbarg_t p)
+{
+    return ((edit_t *) p)->obj_type == OBJ_THINGS;
+}
+
+bool mode_l(micbarg_t p)
+{
+    return ((edit_t *) p)->obj_type == OBJ_LINEDEFS;
+}
+
+bool mode_v(micbarg_t p)
+{
+    return ((edit_t *) p)->obj_type == OBJ_VERTICES;
+}
+
+bool mode_s(micbarg_t p)
+{
+    return ((edit_t *) p)->obj_type == OBJ_SECTORS;
+}
 
 
 /*
   the editor main loop
 */
 
-void EditorLoop (const char *levelname) /* SWAP! */
+void EditorLoop(const char *levelname)	/* SWAP! */
 {
-edit_t e;
+    edit_t e;
 /* FIXME : all these variables should be moved to edit_t : */
-int    RedrawMap;
-bool   DragObject = false, DragMapMove = false;
-int    oldbuttons, DragMapMoveX, DragMapMoveY;
+    int RedrawMap;
+    bool DragObject = false, DragMapMove = false;
+    int oldbuttons, DragMapMoveX, DragMapMoveY;
 
-bool   StretchSelBox = false;  // FIXME apparently not used anymore...
+    bool StretchSelBox = false;	// FIXME apparently not used anymore...
 
-Objid object;			// The object under the pointer
-const Objid CANVAS (OBJ_NONE, OBJ_NO_CANVAS);
+    Objid object;		// The object under the pointer
+    const Objid CANVAS(OBJ_NONE, OBJ_NO_CANVAS);
 
-memset (&e, 0, sizeof e);	/* Catch-all */
-e.move_speed          = 20;
-e.extra_zoom          = 0;
+    memset(&e, 0, sizeof e);	/* Catch-all */
+    e.move_speed = 20;
+    e.extra_zoom = 0;
 // If you change this, don't forget to change
 // the initialisation of the menu bar below.
-e.obj_type            = OBJ_THINGS;
-e.global              = false;
-e.tool                = TOOL_NORMAL;
-e.grid_step           = 128;
-e.grid_step_min       = GridMin;
-e.grid_step_max       = GridMax;
-e.grid_step_locked    = 0;
-e.grid_shown          = 1;
-e.grid_snap           = 1;
-e.infobar_shown       = (bool) InfoShown;
-e.objinfo_shown       = true;
-e.show_object_numbers = false;
-e.show_things_squares = false;
-e.show_things_sprites = true;
-e.rulers_shown        = 0;
-e.clicked.nil ();
+    e.obj_type = OBJ_THINGS;
+    e.global = false;
+    e.tool = TOOL_NORMAL;
+    e.grid_step = 128;
+    e.grid_step_min = GridMin;
+    e.grid_step_max = GridMax;
+    e.grid_step_locked = 0;
+    e.grid_shown = 1;
+    e.grid_snap = 1;
+    e.infobar_shown = (bool) InfoShown;
+    e.objinfo_shown = true;
+    e.show_object_numbers = false;
+    e.show_things_squares = false;
+    e.show_things_sprites = true;
+    e.rulers_shown = 0;
+    e.clicked.nil();
 //e.click_obj_no        = OBJ_NO_NONE;
 //e.click_obj_type      = -1;
-e.click_ctrl          = 0;
-e.highlighted.nil ();
+    e.click_ctrl = 0;
+    e.highlighted.nil();
 //e.highlight_obj_no    = OBJ_NO_NONE;
 //e.highlight_obj_type  = -1;
-e.Selected            = 0;
-e.selbox              = new selbox_c;
-e.edisplay            = new edisplay_c (&e);
-e.menubar             = new menubar_c;
-e.spot                = new spot_c;
-e.modpopup            = new modpopup_c;
-e.modal               = '\0';
+    e.Selected = 0;
+    e.selbox = new selbox_c;
+    e.edisplay = new edisplay_c(&e);
+    e.menubar = new menubar_c;
+    e.spot = new spot_c;
+    e.modpopup = new modpopup_c;
+    e.modal = '\0';
 
-MadeChanges = 0;
-MadeMapChanges = 0;
+    MadeChanges = 0;
+    MadeMapChanges = 0;
 
 // Sane defaults
-Scale = 1.0;
-OrigX = 0;
-OrigY = 0;
+    Scale = 1.0;
+    OrigX = 0;
+    OrigY = 0;
 
-edit_zoom_init ();
+    edit_zoom_init();
 
-if (zoom_default == 0)
-   {
-   zoom_fit (e);
-   }
-else
-   {
-   int r = edit_set_zoom (&e, zoom_default / 100.0);
-   if (r == 0)
-      CenterMapAroundCoords ((MapMinX + MapMaxX) / 2, (MapMinY + MapMaxY) / 2);
-   }
-   oldbuttons = 0;
+    if (zoom_default == 0)
+    {
+	zoom_fit(e);
+    }
+    else
+    {
+	int r = edit_set_zoom(&e, zoom_default / 100.0);
+	if (r == 0)
+	    CenterMapAroundCoords((MapMinX + MapMaxX) / 2,
+				  (MapMinY + MapMaxY) / 2);
+    }
+    oldbuttons = 0;
 
 /* Create the menu bar */
-{
-e.menubar->compute_menubar_coords (0, 0, ScrMaxX, ScrMaxY);
+    {
+	e.menubar->compute_menubar_coords(0, 0, ScrMaxX, ScrMaxY);
 
-e.mb_menu[MBM_FILE] = new Menu (NULL,
-   "~Save",       YK_F2, 0,
-   "Save ~as...", YK_F3, 0,
+	e.mb_menu[MBM_FILE] = new Menu(NULL,
+				       "~Save", YK_F2, 0,
+				       "Save ~as...", YK_F3, 0,
 // "~Print",      YK_,   MIF_SACTIVE, false, 0,
-   "~Quit",       'q',   0,
-   NULL);
+				       "~Quit", 'q', 0, NULL);
 
-e.mb_menu[MBM_EDIT] = new Menu (NULL,
-   "~Copy object(s)",          'o',    0,
-   "~Add object",              YK_INS, 0,
-   "~Delete object(s)",        YK_DEL, 0,
-   "~Exchange object numbers", 24,     0,
-   "~Preferences...",          YK_F5,  0,
-   "~Snap to grid",            'y',    MIF_VTICK, &e.grid_snap,		     0,
-   "~Lock grid step",          'z',    MIF_VTICK, &e.grid_step_locked,	     0,
-   NULL);
+	e.mb_menu[MBM_EDIT] = new Menu(NULL,
+				       "~Copy object(s)", 'o', 0,
+				       "~Add object", YK_INS, 0,
+				       "~Delete object(s)", YK_DEL, 0,
+				       "~Exchange object numbers", 24, 0,
+				       "~Preferences...", YK_F5, 0,
+				       "~Snap to grid", 'y', MIF_VTICK,
+				       &e.grid_snap, 0, "~Lock grid step",
+				       'z', MIF_VTICK, &e.grid_step_locked, 0,
+				       NULL);
 
 // If you change the order of modes here, don't forget
 // to modify the <modes> array.
-e.mb_menu[MBM_VIEW] = new Menu (NULL,
-   "~Things",              't',        MIF_FTICK,   mode_th, (micbarg_t) &e, 0,
-   "~Linedefs & sidedefs", 'l',        MIF_FTICK,   mode_l,  (micbarg_t) &e, 0,
-   "~Vertices",            'v',        MIF_FTICK,   mode_v,  (micbarg_t) &e, 0,
-   "~Sectors",             's',        MIF_FTICK,   mode_s,  (micbarg_t) &e, 0,
-   "Global",               '\7',       MIF_VTICK,   &e.global,               0,
-   "~Next mode",           YK_TAB,     0,
-   "~Prev mode",           YK_BACKTAB, 0,
-   MI_SEPARATION,
-   "Zoom ~in",             '+',        0,
-   "Zoom ~out",            '-',        0,
-   "Extra ~zoom",          ' ',        MIF_VTICK,   &e.extra_zoom,           0,
-   "~Whole level",         '`',        0,
-   MI_SEPARATION,
-   "Show object numbers",  '&',        MIF_VTICK,   &e.show_object_numbers,  0,
-   "Show sprites",         '%',        MIF_VTICK,   &e.show_things_sprites,  0,
-   "Show ~grid",           'h',        MIF_VTICK,   &e.grid_shown,           0,
-   "Info bar",             YK_ALT+'i', MIF_VTICK,   &e.infobar_shown,        0,
-   "Object info boxes",    'i',        MIF_VTICK,   &e.objinfo_shown,        0,
+	e.mb_menu[MBM_VIEW] = new Menu(NULL,
+				       "~Things", 't', MIF_FTICK, mode_th,
+				       (micbarg_t) & e, 0,
+				       "~Linedefs & sidedefs", 'l', MIF_FTICK,
+				       mode_l, (micbarg_t) & e, 0,
+				       "~Vertices", 'v', MIF_FTICK, mode_v,
+				       (micbarg_t) & e, 0, "~Sectors", 's',
+				       MIF_FTICK, mode_s, (micbarg_t) & e, 0,
+				       "Global", '\7', MIF_VTICK, &e.global,
+				       0, "~Next mode", YK_TAB, 0,
+				       "~Prev mode", YK_BACKTAB, 0,
+				       MI_SEPARATION, "Zoom ~in", '+', 0,
+				       "Zoom ~out", '-', 0, "Extra ~zoom",
+				       ' ', MIF_VTICK, &e.extra_zoom, 0,
+				       "~Whole level", '`', 0, MI_SEPARATION,
+				       "Show object numbers", '&', MIF_VTICK,
+				       &e.show_object_numbers, 0,
+				       "Show sprites", '%', MIF_VTICK,
+				       &e.show_things_sprites, 0,
+				       "Show ~grid", 'h', MIF_VTICK,
+				       &e.grid_shown, 0, "Info bar",
+				       YK_ALT + 'i', MIF_VTICK,
+				       &e.infobar_shown, 0,
+				       "Object info boxes", 'i', MIF_VTICK,
+				       &e.objinfo_shown, 0,
 // "3D preview",           '3',        MIF_SACTIVE, false,                   0,
-   NULL);
+				       NULL);
 
-e.mb_menu[MBM_SEARCH] = new Menu (NULL,
+	e.mb_menu[MBM_SEARCH] = new Menu(NULL,
 // "~Find/change",       YK_F4, MIF_SACTIVE, false, 0,
 // "~Repeat last find",  -1,    MIF_SACTIVE, false, 0,
-   "~Next object",       'n',   0,
-   "~Prev object",       'p',   0,
-   "~Jump to object...", 'j',   0,
-   "~Find by type",	 'f',	0,
-   NULL);
+					 "~Next object", 'n', 0,
+					 "~Prev object", 'p', 0,
+					 "~Jump to object...", 'j', 0,
+					 "~Find by type", 'f', 0, NULL);
 
-e.mb_menu[MBM_MISC_L] = new Menu ("Misc. operations",
-   "Find first free ~tag number",		YK_, 0,
-   "~Rotate and scale linedefs...",		YK_, 0,
-   "Split linedefs (add new ~vertex)",		YK_, 0,
-   "~Split linedefs and sector",		YK_, 0,
-   "~Delete linedefs and join sectors",		YK_, 0,
-   "~Flip linedefs",				YK_, 0,
-   "S~wap sidedefs",				YK_, 0,
-   "Align textures (~Y offset)",		YK_, 0,
-   "Align textures (~X offset)...",		YK_, 0,
-   "Remove ~2nd sidedef (make single-sided)",	YK_, 0,
-   "Make rectangular ~nook (32x16)",		YK_, 0,
-   "Make rectangular ~boss (32x16)",		YK_, 0,
-   "Set ~length (move 1st vertex)...",		YK_, 0,
-   "Set length (move 2nd vertex)...",		YK_, 0,
-   "~Unlink 1st sidedef",			YK_, 0,
-   "Unlink 2nd sidedef",			YK_, 0,
-   "~Mirror horizontally",			YK_, 0,
-   "Mirror v~ertically",			YK_, 0,
-   "~Cut a slice out of a sector",		YK_, 0,
-   NULL);
+	e.mb_menu[MBM_MISC_L] = new Menu("Misc. operations",
+					 "Find first free ~tag number", YK_,
+					 0, "~Rotate and scale linedefs...",
+					 YK_, 0,
+					 "Split linedefs (add new ~vertex)",
+					 YK_, 0, "~Split linedefs and sector",
+					 YK_, 0,
+					 "~Delete linedefs and join sectors",
+					 YK_, 0, "~Flip linedefs", YK_, 0,
+					 "S~wap sidedefs", YK_, 0,
+					 "Align textures (~Y offset)", YK_, 0,
+					 "Align textures (~X offset)...", YK_,
+					 0,
+					 "Remove ~2nd sidedef (make single-sided)",
+					 YK_, 0,
+					 "Make rectangular ~nook (32x16)",
+					 YK_, 0,
+					 "Make rectangular ~boss (32x16)",
+					 YK_, 0,
+					 "Set ~length (move 1st vertex)...",
+					 YK_, 0,
+					 "Set length (move 2nd vertex)...",
+					 YK_, 0, "~Unlink 1st sidedef", YK_,
+					 0, "Unlink 2nd sidedef", YK_, 0,
+					 "~Mirror horizontally", YK_, 0,
+					 "Mirror v~ertically", YK_, 0,
+					 "~Cut a slice out of a sector", YK_,
+					 0, NULL);
 
-e.mb_menu[MBM_MISC_S] = new Menu ("Misc. operations",
-   "Find first free ~tag number",	YK_, 0,
-   "~Rotate and scale sectors...",	YK_, 0,
-   "Make ~door from sector",		YK_, 0,
-   "Make ~lift from sector",		YK_, 0,
-   "Distribute sector ~floor heights",	YK_, 0,
-   "Distribute sector ~ceiling heights",YK_, 0,
-   "R~aise or lower sectors...",	YK_, 0,
-   "~Brighten or darken sectors...",	YK_, 0,
-   "~Unlink room",			YK_, 0,
-   "~Mirror horizontally",		YK_, 0,
-   "Mirror ~vertically",		YK_, 0,
-   "~Swap flats",			YK_, 0,
-   NULL);
+	e.mb_menu[MBM_MISC_S] = new Menu("Misc. operations",
+					 "Find first free ~tag number", YK_,
+					 0, "~Rotate and scale sectors...",
+					 YK_, 0, "Make ~door from sector",
+					 YK_, 0, "Make ~lift from sector",
+					 YK_, 0,
+					 "Distribute sector ~floor heights",
+					 YK_, 0,
+					 "Distribute sector ~ceiling heights",
+					 YK_, 0, "R~aise or lower sectors...",
+					 YK_, 0,
+					 "~Brighten or darken sectors...",
+					 YK_, 0, "~Unlink room", YK_, 0,
+					 "~Mirror horizontally", YK_, 0,
+					 "Mirror ~vertically", YK_, 0,
+					 "~Swap flats", YK_, 0, NULL);
 
-e.mb_menu[MBM_MISC_T] = new Menu ("Misc. operations",
-   "Find first free ~tag number",	 YK_, 0,
-   "~Rotate and scale things...",	 YK_, 0,
-   "~Spin things 45° clockwise",	 'x', 0,
-   "Spin things 45° ~counter-clockwise", 'w', 0,
-   "~Mirror horizontally",		 YK_, 0,
-   "Mirror ~vertically",		 YK_, 0,
-   NULL);
+	e.mb_menu[MBM_MISC_T] = new Menu("Misc. operations",
+					 "Find first free ~tag number", YK_,
+					 0, "~Rotate and scale things...",
+					 YK_, 0, "~Spin things 45° clockwise",
+					 'x', 0,
+					 "Spin things 45° ~counter-clockwise",
+					 'w', 0, "~Mirror horizontally", YK_,
+					 0, "Mirror ~vertically", YK_, 0,
+					 NULL);
 
-e.mb_menu[MBM_MISC_V] = new Menu ("Misc. operations",
-   "Find first free ~tag number",	YK_, 0,
-   "~Rotate and scale vertices...",	YK_, 0,
-   "~Delete vertex and join linedefs",	YK_, 0,
-   "~Merge several vertices into one",	YK_, 0,
-   "Add a linedef and ~split sector",	YK_, 0,
-   "Mirror ~horizontally",		YK_, 0,
-   "Mirror ~vertically",		YK_, 0,
-   NULL);
+	e.mb_menu[MBM_MISC_V] = new Menu("Misc. operations",
+					 "Find first free ~tag number", YK_,
+					 0, "~Rotate and scale vertices...",
+					 YK_, 0,
+					 "~Delete vertex and join linedefs",
+					 YK_, 0,
+					 "~Merge several vertices into one",
+					 YK_, 0,
+					 "Add a linedef and ~split sector",
+					 YK_, 0, "Mirror ~horizontally", YK_,
+					 0, "Mirror ~vertically", YK_, 0,
+					 NULL);
 
-e.mb_menu[MBM_OBJECTS] = new Menu ("Insert a pre-defined object",
-   "~Rectangle...",         YK_, 0,
-   "~Polygon (N sides)...", YK_, 0,
-   NULL);
+	e.mb_menu[MBM_OBJECTS] = new Menu("Insert a pre-defined object",
+					  "~Rectangle...", YK_, 0,
+					  "~Polygon (N sides)...", YK_, 0,
+					  NULL);
 
-e.mb_menu[MBM_CHECK] = new Menu ("Check level consistency",
-   "~Number of objects",		YK_, 0,
-   "Check if all ~sectors are closed",	YK_, 0,
-   "Check all ~cross-references",	YK_, 0,
-   "Check for ~missing textures",	YK_, 0,
-   "Check ~texture names",		YK_, 0,
-   NULL);
+	e.mb_menu[MBM_CHECK] = new Menu("Check level consistency",
+					"~Number of objects", YK_, 0,
+					"Check if all ~sectors are closed",
+					YK_, 0, "Check all ~cross-references",
+					YK_, 0, "Check for ~missing textures",
+					YK_, 0, "Check ~texture names", YK_,
+					0, NULL);
 
-e.mb_menu[MBM_HELP] = new Menu (NULL,
-   "~Keyboard & mouse...", YK_F1,        0,
-   "~About Yadex...",      YK_ALT + 'a', 0,
-   NULL);
+	e.mb_menu[MBM_HELP] = new Menu(NULL,
+				       "~Keyboard & mouse...", YK_F1, 0,
+				       "~About Yadex...", YK_ALT + 'a', 0,
+				       NULL);
 
-e.mb_ino[MBI_FILE] =
-   e.menubar->add_item ("File",    0, 0, e.mb_menu[MBM_FILE]   );
-e.mb_ino[MBI_EDIT] =
-   e.menubar->add_item ("Edit",    0, 0, e.mb_menu[MBM_EDIT]   );
-e.mb_ino[MBI_VIEW] =
-   e.menubar->add_item ("View",    0, 0, e.mb_menu[MBM_VIEW]  );
-e.mb_ino[MBI_SEARCH] =
-   e.menubar->add_item ("Search",  0, 0, e.mb_menu[MBM_SEARCH] );
-e.mb_ino[MBI_MISC] =
-   e.menubar->add_item ("Misc",    0, 0, e.mb_menu[MBM_MISC_T] );
-e.mb_ino[MBI_OBJECTS] =
-   e.menubar->add_item ("Objects", 0, 0, e.mb_menu[MBM_OBJECTS]);
-e.mb_ino[MBI_CHECK] =
-   e.menubar->add_item ("Check",   0, 0, e.mb_menu[MBM_CHECK]  );
-e.mb_ino[MBI_HELP] =
-   e.menubar->add_item ("Help",    0, 1, e.mb_menu[MBM_HELP]   );
+	e.mb_ino[MBI_FILE] =
+	    e.menubar->add_item("File", 0, 0, e.mb_menu[MBM_FILE]);
+	e.mb_ino[MBI_EDIT] =
+	    e.menubar->add_item("Edit", 0, 0, e.mb_menu[MBM_EDIT]);
+	e.mb_ino[MBI_VIEW] =
+	    e.menubar->add_item("View", 0, 0, e.mb_menu[MBM_VIEW]);
+	e.mb_ino[MBI_SEARCH] =
+	    e.menubar->add_item("Search", 0, 0, e.mb_menu[MBM_SEARCH]);
+	e.mb_ino[MBI_MISC] =
+	    e.menubar->add_item("Misc", 0, 0, e.mb_menu[MBM_MISC_T]);
+	e.mb_ino[MBI_OBJECTS] =
+	    e.menubar->add_item("Objects", 0, 0, e.mb_menu[MBM_OBJECTS]);
+	e.mb_ino[MBI_CHECK] =
+	    e.menubar->add_item("Check", 0, 0, e.mb_menu[MBM_CHECK]);
+	e.mb_ino[MBI_HELP] =
+	    e.menubar->add_item("Help", 0, 1, e.mb_menu[MBM_HELP]);
 
-menubar_out_y1 = 2 * BOX_BORDER + 2 * NARROW_VSPACING + FONTH - 1;  // FIXME
-}
+	menubar_out_y1 = 2 * BOX_BORDER + 2 * NARROW_VSPACING + FONTH - 1;	// FIXME
+    }
 
 // FIXME this should come from the .ygd
 // instead of being hard-coded.
-Menu *menu_linedef_flags = new Menu (NULL,
-   "~Impassable",		YK_, 0,
-   "~Monsters cannot cross",	YK_, 0,
-   "~Double-sided",		YK_, 0,
-   "~Upper texture unpegged",	YK_, 0,
-   "~Lower texture unpegged",	YK_, 0,
-   "~Secret (shown as normal)",	YK_, 0,
-   "~Blocks sound",		YK_, 0,
-   "~Never shown on the map",	YK_, 0,
-   "~Always shown on the map",	YK_, 0,
-   "~Pass through [Boom]",	YK_, 0,  // Boom extension
-   "b1~0 0400h",		YK_, 0,  // Undefined
-   "b1~1 0800h",		YK_, 0,  // Undefined
-   "~Translucent [Strife]",	YK_, 0,  // Strife
-   "b1~3 2000h",		YK_, 0,  // Undefined
-   "b1~4 4000h",		YK_, 0,  // Undefined
-   "b1~5 8000h",		YK_, 0,  // Undefined
-   NULL);
+    Menu *menu_linedef_flags = new Menu(NULL,
+					"~Impassable", YK_, 0,
+					"~Monsters cannot cross", YK_, 0,
+					"~Double-sided", YK_, 0,
+					"~Upper texture unpegged", YK_, 0,
+					"~Lower texture unpegged", YK_, 0,
+					"~Secret (shown as normal)", YK_, 0,
+					"~Blocks sound", YK_, 0,
+					"~Never shown on the map", YK_, 0,
+					"~Always shown on the map", YK_, 0,
+					"~Pass through [Boom]", YK_, 0,	// Boom extension
+					"b1~0 0400h", YK_, 0,	// Undefined
+					"b1~1 0800h", YK_, 0,	// Undefined
+					"~Translucent [Strife]", YK_, 0,	// Strife
+					"b1~3 2000h", YK_, 0,	// Undefined
+					"b1~4 4000h", YK_, 0,	// Undefined
+					"b1~5 8000h", YK_, 0,	// Undefined
+					NULL);
 
-Menu *menu_thing_flags = new Menu (NULL,
-   "~Easy",			YK_, 0,
-   "Medi~um",			YK_, 0,
-   "~Hard",			YK_, 0,
-   "~Deaf",			YK_, 0,
-   "~Multiplayer",		YK_, 0,
-   "~Not in DM [Boom]",		YK_, 0,  // Boom extension
-   "Not in ~coop [Boom]", 	YK_, 0,  // Boom extension
-   "F~riendly [MBF]",		YK_, 0,  // MBF extension
-   "b~8  0100h",		YK_, 0,  // Undefined
-   "b~9  0200h",		YK_, 0,  // Undefined
-   "b1~0 0400h",		YK_, 0,  // Undefined
-   "b1~1 0800h",		YK_, 0,  // Undefined
-   "b1~2 1000h",		YK_, 0,  // Undefined
-   "b1~3 2000h",		YK_, 0,  // Undefined
-   "b1~4 4000h",		YK_, 0,  // Undefined
-   "b1~5 8000h",		YK_, 0,  // Undefined
-   NULL);
+    Menu *menu_thing_flags = new Menu(NULL,
+				      "~Easy", YK_, 0,
+				      "Medi~um", YK_, 0,
+				      "~Hard", YK_, 0,
+				      "~Deaf", YK_, 0,
+				      "~Multiplayer", YK_, 0,
+				      "~Not in DM [Boom]", YK_, 0,	// Boom extension
+				      "Not in ~coop [Boom]", YK_, 0,	// Boom extension
+				      "F~riendly [MBF]", YK_, 0,	// MBF extension
+				      "b~8  0100h", YK_, 0,	// Undefined
+				      "b~9  0200h", YK_, 0,	// Undefined
+				      "b1~0 0400h", YK_, 0,	// Undefined
+				      "b1~1 0800h", YK_, 0,	// Undefined
+				      "b1~2 1000h", YK_, 0,	// Undefined
+				      "b1~3 2000h", YK_, 0,	// Undefined
+				      "b1~4 4000h", YK_, 0,	// Undefined
+				      "b1~5 8000h", YK_, 0,	// Undefined
+				      NULL);
 
 /* AYM 1998-06-22
    This is the big mean loop. I organized it in three main steps :
@@ -462,1991 +497,2042 @@
    hesitate to ask me. You never know, I might help you to be even more
    confused. ;-) */
 
-for (RedrawMap = 1; ; RedrawMap = 0)
-   {
-   int motion = 0;  // Initialized to silence GCC warning
+    for (RedrawMap = 1;; RedrawMap = 0)
+    {
+	int motion = 0;		// Initialized to silence GCC warning
 
-   /*
-    *  Step 1 -- Do all the displaying work
-    */
+	/*
+	 *  Step 1 -- Do all the displaying work
+	 */
 
 #ifdef Y_BATCH
-   // Hold refresh until all events are processed
-   if (! has_event () && ! has_input_event ())
-      {
+	// Hold refresh until all events are processed
+	if (!has_event() && !has_input_event())
+	{
 #endif
-      if (e.highlighted ())				// FIXME
-	 e.edisplay->highlight_object (e.highlighted);	// Should
-      else						// be in
-	 e.edisplay->forget_highlight ();		// edisplay_c !
+	    if (e.highlighted())	// FIXME
+		e.edisplay->highlight_object(e.highlighted);	// Should
+	    else		// be in
+		e.edisplay->forget_highlight();	// edisplay_c !
 
-   if (is.in_window)
-      e.spot->set (edit_mapx_snapped (&e, e.pointer_x),
-                   edit_mapy_snapped (&e, e.pointer_y));
-   else
-      e.spot->unset ();
+	    if (is.in_window)
+		e.spot->set(edit_mapx_snapped(&e, e.pointer_x),
+			    edit_mapy_snapped(&e, e.pointer_y));
+	    else
+		e.spot->unset();
 
-      e.edisplay->refresh ();
-      /* The display is now up to date */
+	    e.edisplay->refresh();
+	    /* The display is now up to date */
 #ifdef Y_BATCH
-      }
+	}
 #endif
 
 
-   /*
-    *  Step 2 -- Get the next event
-    */
+	/*
+	 *  Step 2 -- Get the next event
+	 */
 
-   if (has_key_press_event ())
-      is.key = get_event ();
-   else
-      get_input_status ();
-   e.pointer_in_window = is.in_window;
-   if (is.in_window)
-      {
-      /* AYM 1998-07-04
-	 If the map coordinates of the pointer have changed,
-	 generate a pointer motion event. I don't like to do
-	 that but it makes things much simpler elsewhere. */
-      if (MAPX (is.x) != e.pointer_x || MAPY (is.y) != e.pointer_y)
-	 motion = 1;
-      else
-	 motion = 0;
+	if (has_key_press_event())
+	    is.key = get_event();
+	else
+	    get_input_status();
+	e.pointer_in_window = is.in_window;
+	if (is.in_window)
+	{
+	    /* AYM 1998-07-04
+	       If the map coordinates of the pointer have changed,
+	       generate a pointer motion event. I don't like to do
+	       that but it makes things much simpler elsewhere. */
+	    if (MAPX(is.x) != e.pointer_x || MAPY(is.y) != e.pointer_y)
+		motion = 1;
+	    else
+		motion = 0;
 
-      e.pointer_x = MAPX (is.x);
-      e.pointer_y = MAPY (is.y);
-      obj_type_t t = e.global ? OBJ_ANY : e.obj_type;
-      GetCurObject (object, t, e.pointer_x, e.pointer_y);
-      }
-
-   /*
-    *  Step 3 -- Process the event
-    *  This section is (should be) a long list of elif's
-    */
+	    e.pointer_x = MAPX(is.x);
+	    e.pointer_y = MAPY(is.y);
+	    obj_type_t t = e.global ? OBJ_ANY : e.obj_type;
+	    GetCurObject(object, t, e.pointer_x, e.pointer_y);
+	}
 
-   /*
-    *	Step 3.1A -- If a pull-down menu is "on",
-    *	try to make it process the event.
-    */
+	/*
+	 *  Step 3 -- Process the event
+	 *  This section is (should be) a long list of elif's
+	 */
 
-   if (e.menubar->pulled_down () >= 0)
-      {
-      int menu_no = e.menubar->pulled_down ();
-      Menu *menu = e.menubar->get_menu (menu_no);
-      int r = menu->process_event (&is);
+	/*
+	 *   Step 3.1A -- If a pull-down menu is "on",
+	 *   try to make it process the event.
+	 */
 
-      if (r == MEN_CANCEL)
-	 {
-	 e.menubar->pull_down (-1);
-	 e.menubar->highlight (-1);
-         goto done;
-	 }
+	if (e.menubar->pulled_down() >= 0)
+	{
+	    int menu_no = e.menubar->pulled_down();
+	    Menu *menu = e.menubar->get_menu(menu_no);
+	    int r = menu->process_event(&is);
 
-      // The event was understood and processed normally
-      // by the menu event handler so we're done.
-      else if (r == MEN_OTHER)
-	 goto done;
+	    if (r == MEN_CANCEL)
+	    {
+		e.menubar->pull_down(-1);
+		e.menubar->highlight(-1);
+		goto done;
+	    }
 
-      // The event was not understood by the menu event
-      // handler so let's see what the normal event handler
-      // can do with it.
-      else if (r == MEN_INVALID)
-	 ;
+	    // The event was understood and processed normally
+	    // by the menu event handler so we're done.
+	    else if (r == MEN_OTHER)
+		goto done;
 
-      else
-	 {
-	 e.menubar->pull_down (-1);
-	 e.menubar->highlight (-1);
-	 if (menu_no == e.mb_ino[MBI_MISC])
-	    {
-	    if (e.Selected)
-	       MiscOperations (e.obj_type, &e.Selected, r + 1);
+	    // The event was not understood by the menu event
+	    // handler so let's see what the normal event handler
+	    // can do with it.
+	    else if (r == MEN_INVALID)
+		;
+
 	    else
-	       {
-	       if (e.highlighted ())
-		  SelectObject (&e.Selected, e.highlighted.num);
-	       MiscOperations (e.obj_type, &e.Selected, r + 1);
-	       if (e.highlighted ())
-		  UnSelectObject (&e.Selected, e.highlighted.num);
-	       }
-	    e.highlighted.nil ();
-	    DragObject = false;
-	    StretchSelBox = false;
-	    RedrawMap = 1;
-	    }
-	 else if (menu_no == e.mb_ino[MBI_OBJECTS])
-            {
-	    /* code duplicated from 'F9' - I hate to do that */
-	    int savednum = NumLineDefs;
-	    InsertStandardObject (e.pointer_x, e.pointer_y, r + 1);
-	    if (NumLineDefs > savednum)
-	       {
-	       ForgetSelection (&e.Selected);
-	       e.obj_type = OBJ_LINEDEFS;
-	       for (int i = savednum; i < NumLineDefs; i++)
-		  SelectObject (&e.Selected, i);
-	       e.highlighted.nil ();
-	       DragObject = false;
-	       StretchSelBox = false;
-	       }
-	    RedrawMap = 1;
-            }
-	 else if (menu_no == e.mb_ino[MBI_CHECK])
 	    {
-	    if (r == 0)
-	       Statistics ();
-	    else if (r == 1)
-	       CheckSectors ();
-	    else if (r == 2)
-	       CheckCrossReferences ();
-	    else if (r == 3)
-	       CheckTextures ();
-	    else if (r == 4)
-	       CheckTextureNames ();
+		e.menubar->pull_down(-1);
+		e.menubar->highlight(-1);
+		if (menu_no == e.mb_ino[MBI_MISC])
+		{
+		    if (e.Selected)
+			MiscOperations(e.obj_type, &e.Selected, r + 1);
+		    else
+		    {
+			if (e.highlighted())
+			    SelectObject(&e.Selected, e.highlighted.num);
+			MiscOperations(e.obj_type, &e.Selected, r + 1);
+			if (e.highlighted())
+			    UnSelectObject(&e.Selected, e.highlighted.num);
+		    }
+		    e.highlighted.nil();
+		    DragObject = false;
+		    StretchSelBox = false;
+		    RedrawMap = 1;
+		}
+		else if (menu_no == e.mb_ino[MBI_OBJECTS])
+		{
+		    /* code duplicated from 'F9' - I hate to do that */
+		    int savednum = NumLineDefs;
+		    InsertStandardObject(e.pointer_x, e.pointer_y, r + 1);
+		    if (NumLineDefs > savednum)
+		    {
+			ForgetSelection(&e.Selected);
+			e.obj_type = OBJ_LINEDEFS;
+			for (int i = savednum; i < NumLineDefs; i++)
+			    SelectObject(&e.Selected, i);
+			e.highlighted.nil();
+			DragObject = false;
+			StretchSelBox = false;
+		    }
+		    RedrawMap = 1;
+		}
+		else if (menu_no == e.mb_ino[MBI_CHECK])
+		{
+		    if (r == 0)
+			Statistics();
+		    else if (r == 1)
+			CheckSectors();
+		    else if (r == 2)
+			CheckCrossReferences();
+		    else if (r == 3)
+			CheckTextures();
+		    else if (r == 4)
+			CheckTextureNames();
+		}
+		else
+		    send_event(menu->last_shortcut_key());
+		goto done;
 	    }
-	 else
-	    send_event (menu->last_shortcut_key ());
-         goto done;
-	 }
-      }
+	}
 
-   /*
-    *	Step 3.1B -- If the "Misc operations" popup is on,
-    *	try to make it process the event.
-    */
+	/*
+	 *   Step 3.1B -- If the "Misc operations" popup is on,
+	 *   try to make it process the event.
+	 */
 
-   else if (e.modpopup->get () == e.mb_menu[MBM_MISC_L]
-      || e.modpopup->get () == e.mb_menu[MBM_MISC_S]
-      || e.modpopup->get () == e.mb_menu[MBM_MISC_T]
-      || e.modpopup->get () == e.mb_menu[MBM_MISC_V])
-      {
-      int r = (e.modpopup->get ())->process_event (&is);
+	else if (e.modpopup->get() == e.mb_menu[MBM_MISC_L]
+		 || e.modpopup->get() == e.mb_menu[MBM_MISC_S]
+		 || e.modpopup->get() == e.mb_menu[MBM_MISC_T]
+		 || e.modpopup->get() == e.mb_menu[MBM_MISC_V])
+	{
+	    int r = (e.modpopup->get())->process_event(&is);
 
-      // [Esc] or click outside the popup menu. Close it.
-      if (r == MEN_CANCEL
-         || r == MEN_INVALID && is.key == YE_BUTL_PRESS)
-	 {
-         e.modpopup->unset ();
-         goto done2;
-	 }
+	    // [Esc] or click outside the popup menu. Close it.
+	    if (r == MEN_CANCEL
+		|| r == MEN_INVALID && is.key == YE_BUTL_PRESS)
+	    {
+		e.modpopup->unset();
+		goto done2;
+	    }
 
-      // The event was understood and processed normally
-      // by the menu event handler so we're done.
-      else if (r == MEN_OTHER)
-	 goto done2;
+	    // The event was understood and processed normally
+	    // by the menu event handler so we're done.
+	    else if (r == MEN_OTHER)
+		goto done2;
+
+	    // The event was not understood by the menu event
+	    // handler so let's see what the normal event handler
+	    // can do with it.
+	    else if (r == MEN_INVALID)
+		;
 
-      // The event was not understood by the menu event
-      // handler so let's see what the normal event handler
-      // can do with it.
-      else if (r == MEN_INVALID)
-	 ;
-
-      else
-	 {
-         e.modpopup->unset ();
-	 if (e.Selected)
-	    MiscOperations (e.obj_type, &e.Selected, r + 1);
-	 else
+	    else
 	    {
-	    if (e.highlighted ())
-	       SelectObject (&e.Selected, e.highlighted.num);
-	    MiscOperations (e.obj_type, &e.Selected, r + 1);
-	    if (e.highlighted ())
-	       UnSelectObject (&e.Selected, e.highlighted.num);
+		e.modpopup->unset();
+		if (e.Selected)
+		    MiscOperations(e.obj_type, &e.Selected, r + 1);
+		else
+		{
+		    if (e.highlighted())
+			SelectObject(&e.Selected, e.highlighted.num);
+		    MiscOperations(e.obj_type, &e.Selected, r + 1);
+		    if (e.highlighted())
+			UnSelectObject(&e.Selected, e.highlighted.num);
+		}
+		e.highlighted.nil();
+		DragObject = false;
+		StretchSelBox = false;
+		goto done2;
 	    }
-	 e.highlighted.nil ();
-	 DragObject = false;
-	 StretchSelBox = false;
-	 goto done2;
-	 }
-      }
+	}
+
+	/*
+	 *   Step 3.1C -- If the "Insert standard object" popup is on,
+	 *   try to make it process the event.
+	 */
 
-   /*
-    *	Step 3.1C -- If the "Insert standard object" popup is on,
-    *	try to make it process the event.
-    */
+	else if (e.modpopup->get() == e.mb_menu[MBM_OBJECTS])
+	{
+	    int r = (e.modpopup->get())->process_event(&is);
 
-   else if (e.modpopup->get () == e.mb_menu[MBM_OBJECTS])
-      {
-      int r = (e.modpopup->get ())->process_event (&is);
+	    // [Esc] or click outside the popup menu. Close it.
+	    if (r == MEN_CANCEL
+		|| r == MEN_INVALID && is.key == YE_BUTL_PRESS)
+	    {
+		e.modpopup->unset();
+		goto done2;
+	    }
 
-      // [Esc] or click outside the popup menu. Close it.
-      if (r == MEN_CANCEL
-         || r == MEN_INVALID && is.key == YE_BUTL_PRESS)
-	 {
-         e.modpopup->unset ();
-         goto done2;
-	 }
+	    // The event was understood and processed normally
+	    // by the menu event handler so we're done.
+	    else if (r == MEN_OTHER)
+		goto done2;
 
-      // The event was understood and processed normally
-      // by the menu event handler so we're done.
-      else if (r == MEN_OTHER)
-	 goto done2;
-
-      // The event was not understood by the menu event
-      // handler so let's see what the normal event handler
-      // can do with it.
-      else if (r == MEN_INVALID)
-	 ;
+	    // The event was not understood by the menu event
+	    // handler so let's see what the normal event handler
+	    // can do with it.
+	    else if (r == MEN_INVALID)
+		;
 
-      else
-	 {
-         e.modpopup->unset ();
-	 int savednum = NumLineDefs;
-	 InsertStandardObject (e.pointer_x, e.pointer_y, r + 1);
-	 if (NumLineDefs > savednum)
+	    else
 	    {
-	    ForgetSelection (&e.Selected);
-	    e.obj_type = OBJ_LINEDEFS;
-	    for (int i = savednum; i < NumLineDefs; i++)
-	       SelectObject (&e.Selected, i);
-	    e.highlighted.nil ();
-	    DragObject = false;
-	    StretchSelBox = false;
+		e.modpopup->unset();
+		int savednum = NumLineDefs;
+		InsertStandardObject(e.pointer_x, e.pointer_y, r + 1);
+		if (NumLineDefs > savednum)
+		{
+		    ForgetSelection(&e.Selected);
+		    e.obj_type = OBJ_LINEDEFS;
+		    for (int i = savednum; i < NumLineDefs; i++)
+			SelectObject(&e.Selected, i);
+		    e.highlighted.nil();
+		    DragObject = false;
+		    StretchSelBox = false;
+		}
+		goto done2;
 	    }
-         goto done2;
-	 }
-      }
+	}
+
+	/*
+	 *   Step 3.1D -- if the "Set/toggle/clear" linedef flag popup
+	 *   is on, try to make it process the event.
+	 */
+	else if (e.modpopup->get() == menu_linedef_flags)
+	{
+	    int r = (e.modpopup->get())->process_event(&is);
+
+	    // [Esc] or click outside the popup menu. Close it.
+	    if (r == MEN_CANCEL
+		|| r == MEN_INVALID && is.key == YE_BUTL_PRESS)
+	    {
+		e.modpopup->unset();
+		goto done2;
+	    }
 
-   /*
-    *	Step 3.1D -- if the "Set/toggle/clear" linedef flag popup
-    *	is on, try to make it process the event.
-    */
-   else if (e.modpopup->get () == menu_linedef_flags)
-      {
-      int r = (e.modpopup->get ())->process_event (&is);
+	    // The event was understood and processed normally
+	    // by the menu event handler so we're done.
+	    else if (r == MEN_OTHER)
+		goto done2;
+
+	    // The event was not understood by the menu event
+	    // handler so let's see what the normal event handler
+	    // can do with it.
+	    else if (r == MEN_INVALID)
+		;
 
-      // [Esc] or click outside the popup menu. Close it.
-      if (r == MEN_CANCEL
-         || r == MEN_INVALID && is.key == YE_BUTL_PRESS)
-	 {
-         e.modpopup->unset ();
-         goto done2;
-	 }
+	    else
+	    {
+		int op = -1;
+		e.modpopup->unset();
+		if (e.modal == 's')
+		    op = YO_SET;
+		else if (e.modal == 't')
+		    op = YO_TOGGLE;
+		else if (e.modal == 'c')
+		    op = YO_CLEAR;
+		else
+		    fatal_error("modal=%02X", e.modal);
+		if (!e.Selected)
+		{
+		    SelectObject(&e.Selected, e.highlighted.num);
+		    frob_linedefs_flags(e.Selected, op, r);
+		    UnSelectObject(&e.Selected, e.highlighted.num);
+		}
+		else
+		{
+		    frob_linedefs_flags(e.Selected, op, r);
+		}
+		goto done2;
+	    }
+	}
 
-      // The event was understood and processed normally
-      // by the menu event handler so we're done.
-      else if (r == MEN_OTHER)
-	 goto done2;
-
-      // The event was not understood by the menu event
-      // handler so let's see what the normal event handler
-      // can do with it.
-      else if (r == MEN_INVALID)
-	 ;
+	/*
+	 *   Step 3.1E -- if the "Set/toggle/clear" thing flag popup
+	 *   is on, try to make it process the event.
+	 */
+	else if (e.modpopup->get() == menu_thing_flags)
+	{
+	    int r = (e.modpopup->get())->process_event(&is);
 
-      else
-	 {
-         int op = -1;
-         e.modpopup->unset ();
-         if (e.modal == 's')
-            op = YO_SET;
-         else if (e.modal == 't')
-            op = YO_TOGGLE;
-         else if (e.modal == 'c')
-            op = YO_CLEAR;
-         else
-            fatal_error ("modal=%02X", e.modal);
-         if (! e.Selected)
-            {
-            SelectObject (&e.Selected, e.highlighted.num);
-            frob_linedefs_flags (e.Selected, op, r);
-            UnSelectObject (&e.Selected, e.highlighted.num);
-            }
-         else
-            {
-            frob_linedefs_flags (e.Selected, op, r);
-            }
-         goto done2;
-	 }
-      }
+	    // [Esc] or click outside the popup menu. Close it.
+	    if (r == MEN_CANCEL
+		|| r == MEN_INVALID && is.key == YE_BUTL_PRESS)
+	    {
+		e.modpopup->unset();
+		goto done2;
+	    }
+
+	    // The event was understood and processed normally
+	    // by the menu event handler so we're done.
+	    else if (r == MEN_OTHER)
+		goto done2;
+
+	    // The event was not understood by the menu event
+	    // handler so let's see what the normal event handler
+	    // can do with it.
+	    else if (r == MEN_INVALID)
+		;
 
-   /*
-    *	Step 3.1E -- if the "Set/toggle/clear" thing flag popup
-    *	is on, try to make it process the event.
-    */
-   else if (e.modpopup->get () == menu_thing_flags)
-      {
-      int r = (e.modpopup->get ())->process_event (&is);
-
-      // [Esc] or click outside the popup menu. Close it.
-      if (r == MEN_CANCEL
-         || r == MEN_INVALID && is.key == YE_BUTL_PRESS)
-	 {
-         e.modpopup->unset ();
-         goto done2;
-	 }
-
-      // The event was understood and processed normally
-      // by the menu event handler so we're done.
-      else if (r == MEN_OTHER)
-	 goto done2;
-
-      // The event was not understood by the menu event
-      // handler so let's see what the normal event handler
-      // can do with it.
-      else if (r == MEN_INVALID)
-	 ;
+	    else
+	    {
+		int op = -1;
+		e.modpopup->unset();
+		if (e.modal == 's')
+		    op = YO_SET;
+		else if (e.modal == 't')
+		    op = YO_TOGGLE;
+		else if (e.modal == 'c')
+		    op = YO_CLEAR;
+		else
+		    fatal_error("modal=%02X", e.modal);
+		if (!e.Selected)
+		{
+		    SelectObject(&e.Selected, e.highlighted.num);
+		    frob_things_flags(e.Selected, op, r);
+		    UnSelectObject(&e.Selected, e.highlighted.num);
+		}
+		else
+		{
+		    frob_things_flags(e.Selected, op, r);
+		}
+		goto done2;
+	    }
+	}
 
-      else
-         {
-         int op = -1;
-         e.modpopup->unset ();
-         if (e.modal == 's')
-            op = YO_SET;
-         else if (e.modal == 't')
-            op = YO_TOGGLE;
-         else if (e.modal == 'c')
-            op = YO_CLEAR;
-         else
-            fatal_error ("modal=%02X", e.modal);
-         if (! e.Selected)
-            {
-            SelectObject (&e.Selected, e.highlighted.num);
-            frob_things_flags (e.Selected, op, r);
-            UnSelectObject (&e.Selected, e.highlighted.num);
-            }
-         else
-            {
-            frob_things_flags (e.Selected, op, r);
-            }
-         goto done2;
-	 }
-      }
+	/*
+	 *   Step 3.2 -- "Normal" event handling
+	 */
+
+	/*
+	 *   Step 3.2.1 -- Non keyboard events
+	 */
+
+	if (is.key == YE_EXPOSE)
+	{
+	    RedrawMap = 1;
+	    goto done2;
+	}
 
-   /*
-    *	Step 3.2 -- "Normal" event handling
-    */
+	else if (is.key == YE_RESIZE)
+	{
+	    SetWindowSize(is.width, is.height);
+	    e.menubar->compute_menubar_coords(0, 0, ScrMaxX, ScrMaxY);
+	    RedrawMap = 1;
+	    goto done2;
+	}
 
-   /*
-    *	Step 3.2.1 -- Non keyboard events
-    */
+	// To prevent normal handling when a popup menu is on.
+	if (e.modpopup->get() != 0)
+	{
+	    goto done2;
+	}
 
-   if (is.key == YE_EXPOSE)
-      {
-      RedrawMap = 1;
-      goto done2;
-      }
+	/*
+	 *   Step 3.2.2 -- Mouse events
+	 */
+	if (DragMapMove && is.key == YE_MOTION)
+	{
+	    int deltaX = DragMapMoveX - is.x, deltaY = DragMapMoveY - is.y;
 
-   else if (is.key == YE_RESIZE)
-      {
-      SetWindowSize (is.width, is.height);
-      e.menubar->compute_menubar_coords (0, 0, ScrMaxX, ScrMaxY);
-      RedrawMap = 1;
-      goto done2;
-      }
-
-   // To prevent normal handling when a popup menu is on.
-   if (e.modpopup->get () != 0)
-      {
-      goto done2;
-      }
+	    if (deltaX != 0 || deltaY != 0)
+	    {
+		OrigX += (deltaX / Scale);
+		OrigY -= (deltaY / Scale);
+		RedrawMap = 1;
+		DragMapMoveX = is.x;
+		DragMapMoveY = is.y;
+		goto done2;
+	    }
+	}
 
-   /*
-    *	Step 3.2.2 -- Mouse events
-    */
-   if (DragMapMove && is.key == YE_MOTION) {
-        int deltaX = DragMapMoveX - is.x,
-            deltaY = DragMapMoveY - is.y;
-        
-        if (deltaX != 0 || deltaY != 0) {
-            OrigX += (deltaX / Scale);
-            OrigY -= (deltaY / Scale);
-            RedrawMap = 1;
-            DragMapMoveX = is.x;
-            DragMapMoveY = is.y;
-            goto done2;
-        }
-   }
+	else if (is.key == YE_BUTM_PRESS)
+	{
+	    DragMapMove = true;
+	    DragMapMoveX = is.x;
+	    DragMapMoveY = is.y;
+	    goto done;
+	}
 
-   else if (is.key == YE_BUTM_PRESS) {
-        DragMapMove = true;
-        DragMapMoveX = is.x;
-        DragMapMoveY = is.y;
-        goto done;
-   }
+	else if (is.key == YE_BUTM_RELEASE)
+	{
+	    DragMapMove = false;
+	    goto done;
+	}
+
+	// Clicking on an item of the menu bar
+	// pulls down the corresponding menu.
+	else if (is.key == YE_BUTL_PRESS
+		 && e.menubar->is_on_menubar_item(is.x, is.y) >= 0)
+	{
+	    int itemno;
 
-   else if (is.key == YE_BUTM_RELEASE) {
-        DragMapMove = false;
-        goto done;
-   }
-
-   // Clicking on an item of the menu bar
-   // pulls down the corresponding menu.
-   else if (is.key == YE_BUTL_PRESS
-      && e.menubar->is_on_menubar_item (is.x, is.y) >= 0)
-      {
-      int itemno;
+	    e.clicked.nil();
+	    itemno = e.menubar->is_on_menubar_item(is.x, is.y);
+	    if (itemno >= 0)
+		e.menubar->pull_down(itemno);
+	    else
+		Beep();
+	    goto done;
+	}
 
-      e.clicked.nil ();
-      itemno = e.menubar->is_on_menubar_item (is.x, is.y);
-      if (itemno >= 0)
-         e.menubar->pull_down (itemno);
-      else
-         Beep ();
-      goto done;
-      }
-
-   /* Clicking on an empty space starts a new selection box.
-      Unless [Ctrl] is pressed, it also clears the current selection. */
-   else if (is.key == YE_BUTL_PRESS
-	 && e.tool == TOOL_NORMAL
-	 && object.is_nil ())
-      {
-      e.menubar->highlight (-1);  // Close any open menu
-      e.clicked    = CANVAS;
-      e.click_ctrl = is.ctrl;
-      if (! is.ctrl)
-         {
-         ForgetSelection (&e.Selected);
-         RedrawMap = 1;
-         }
-      e.selbox->set_1st_corner (e.pointer_x, e.pointer_y);
-      e.selbox->set_2nd_corner (e.pointer_x, e.pointer_y);
-      }
+	/* Clicking on an empty space starts a new selection box.
+	   Unless [Ctrl] is pressed, it also clears the current selection. */
+	else if (is.key == YE_BUTL_PRESS
+		 && e.tool == TOOL_NORMAL && object.is_nil())
+	{
+	    e.menubar->highlight(-1);	// Close any open menu
+	    e.clicked = CANVAS;
+	    e.click_ctrl = is.ctrl;
+	    if (!is.ctrl)
+	    {
+		ForgetSelection(&e.Selected);
+		RedrawMap = 1;
+	    }
+	    e.selbox->set_1st_corner(e.pointer_x, e.pointer_y);
+	    e.selbox->set_2nd_corner(e.pointer_x, e.pointer_y);
+	}
 
-   /* Clicking on an unselected object unselects
-      everything but that object. Additionally,
-      we write the number of the object in case
-      the user is about to drag it. */
-   else if (is.key == YE_BUTL_PRESS && ! is.ctrl
-	 && e.tool == TOOL_NORMAL
-	 && ! IsSelected (e.Selected, object.num))
-      {
-      e.menubar->highlight (-1);  // Close any open menu
-      e.clicked        = object;
-      e.click_ctrl     = 0;
-      e.click_time     = is.time;
-      ForgetSelection (&e.Selected);
-      SelectObject (&e.Selected, object.num);
-      /* I don't like having to do that */
-      if (object.type == OBJ_THINGS && object ())
-	 MoveObjectsToCoords (object.type, 0,
-            Things[object.num].xpos, Things[object.num].ypos, 0);
-      else if (object.type == OBJ_VERTICES && object ())
-	 MoveObjectsToCoords (object.type, 0,
-            Vertices[object.num].x, Vertices[object.num].y, 0);
-      else
-	 MoveObjectsToCoords (object.type, 0,
-            e.pointer_x, e.pointer_y, e.grid_snap ? e.grid_step : 0);
-      RedrawMap = 1;
-      }
+	/* Clicking on an unselected object unselects
+	   everything but that object. Additionally,
+	   we write the number of the object in case
+	   the user is about to drag it. */
+	else if (is.key == YE_BUTL_PRESS && !is.ctrl
+		 && e.tool == TOOL_NORMAL
+		 && !IsSelected(e.Selected, object.num))
+	{
+	    e.menubar->highlight(-1);	// Close any open menu
+	    e.clicked = object;
+	    e.click_ctrl = 0;
+	    e.click_time = is.time;
+	    ForgetSelection(&e.Selected);
+	    SelectObject(&e.Selected, object.num);
+	    /* I don't like having to do that */
+	    if (object.type == OBJ_THINGS && object())
+		MoveObjectsToCoords(object.type, 0,
+				    Things[object.num].xpos,
+				    Things[object.num].ypos, 0);
+	    else if (object.type == OBJ_VERTICES && object())
+		MoveObjectsToCoords(object.type, 0,
+				    Vertices[object.num].x,
+				    Vertices[object.num].y, 0);
+	    else
+		MoveObjectsToCoords(object.type, 0,
+				    e.pointer_x, e.pointer_y,
+				    e.grid_snap ? e.grid_step : 0);
+	    RedrawMap = 1;
+	}
 
-   /* Second click of a double click on an object */
-   else if (is.key == YE_BUTL_PRESS && ! is.ctrl
-	 && e.tool == TOOL_NORMAL
-	 && IsSelected (e.Selected, object.num)
-	 && object  == e.clicked
-	 && is.time - e.click_time <= (unsigned long) double_click_timeout)
-      {
-      // Very important! If you don't do that, the release of the
-      // click that closed the properties menu will drag the object.
-      e.clicked.nil ();
-      send_event (YK_RETURN);
-      goto done;
-      }
+	/* Second click of a double click on an object */
+	else if (is.key == YE_BUTL_PRESS && !is.ctrl
+		 && e.tool == TOOL_NORMAL
+		 && IsSelected(e.Selected, object.num)
+		 && object == e.clicked
+		 && is.time - e.click_time <=
+		 (unsigned long) double_click_timeout)
+	{
+	    // Very important! If you don't do that, the release of the
+	    // click that closed the properties menu will drag the object.
+	    e.clicked.nil();
+	    send_event(YK_RETURN);
+	    goto done;
+	}
 
-   /* Clicking on a selected object does nothing ;
-      the user might want to drag the selection. */
-   else if (is.key == YE_BUTL_PRESS && ! is.ctrl
-	 && e.tool == TOOL_NORMAL
-	 && IsSelected (e.Selected, object.num))
-      {
-      e.menubar->highlight (-1);  // Close any open menu
-      e.clicked        = object;
-      e.click_ctrl     = 0;
-      e.click_time     = is.time;
-      /* I don't like having to do that */
-      if (object.type == OBJ_THINGS && object ())
-	 MoveObjectsToCoords (object.type, 0,
-            Things[object.num].xpos, Things[object.num].ypos, 0);
-      else if (object.type == OBJ_VERTICES && object ())
-	 MoveObjectsToCoords (object.type, 0,
-            Vertices[object.num].x, Vertices[object.num].y, 0);
-      else
-	 MoveObjectsToCoords (object.type, 0,
-            e.pointer_x, e.pointer_y, e.grid_snap ? e.grid_step : 0);
-      }
+	/* Clicking on a selected object does nothing ;
+	   the user might want to drag the selection. */
+	else if (is.key == YE_BUTL_PRESS && !is.ctrl
+		 && e.tool == TOOL_NORMAL
+		 && IsSelected(e.Selected, object.num))
+	{
+	    e.menubar->highlight(-1);	// Close any open menu
+	    e.clicked = object;
+	    e.click_ctrl = 0;
+	    e.click_time = is.time;
+	    /* I don't like having to do that */
+	    if (object.type == OBJ_THINGS && object())
+		MoveObjectsToCoords(object.type, 0,
+				    Things[object.num].xpos,
+				    Things[object.num].ypos, 0);
+	    else if (object.type == OBJ_VERTICES && object())
+		MoveObjectsToCoords(object.type, 0,
+				    Vertices[object.num].x,
+				    Vertices[object.num].y, 0);
+	    else
+		MoveObjectsToCoords(object.type, 0,
+				    e.pointer_x, e.pointer_y,
+				    e.grid_snap ? e.grid_step : 0);
+	}
 
-   /* Clicking on selected object with [Ctrl] pressed unselects it.
-      Clicking on unselected object with [Ctrl] pressed selects it. */
-   else if (((is.key == YE_BUTL_PRESS && is.ctrl) || is.key == YE_BUTR_PRESS)
-	 && e.tool == TOOL_NORMAL
-	 && object ())
-      {
-      e.menubar->highlight (-1);  // Close any open menu
-      e.clicked        = object;
-      e.click_ctrl     = 1;
-      if (IsSelected (e.Selected, object.num))
-	UnSelectObject (&e.Selected, object.num);
-      else
-	SelectObject (&e.Selected, object.num);
-      RedrawMap = 1;
-      }
+	/* Clicking on selected object with [Ctrl] pressed unselects it.
+	   Clicking on unselected object with [Ctrl] pressed selects it. */
+	else if (((is.key == YE_BUTL_PRESS && is.ctrl)
+		  || is.key == YE_BUTR_PRESS) && e.tool == TOOL_NORMAL
+		 && object())
+	{
+	    e.menubar->highlight(-1);	// Close any open menu
+	    e.clicked = object;
+	    e.click_ctrl = 1;
+	    if (IsSelected(e.Selected, object.num))
+		UnSelectObject(&e.Selected, object.num);
+	    else
+		SelectObject(&e.Selected, object.num);
+	    RedrawMap = 1;
+	}
 
-   /* TOOL_SNAP_VERTEX */
-   else if (is.key == YE_BUTL_PRESS
-	    && e.tool == TOOL_SNAP_VERTEX
-	    && e.obj_type == OBJ_VERTICES
-	    && object ()
-	    // Can't delete vertex that is referenced by the selection
-	    && ! IsSelected (e.Selected, object.num))
-      {
-      printf ("SNAP %d\n", (int) object.num);
-      SelPtr list = 0;
-      SelectObject (&list, object.num);
-      DeleteVerticesJoinLineDefs (list);
-      ForgetSelection (&list);
-      RedrawMap = 1;
-      }
+	/* TOOL_SNAP_VERTEX */
+	else if (is.key == YE_BUTL_PRESS
+		 && e.tool == TOOL_SNAP_VERTEX
+		 && e.obj_type == OBJ_VERTICES && object()
+		 // Can't delete vertex that is referenced by the selection
+		 && !IsSelected(e.Selected, object.num))
+	{
+	    printf("SNAP %d\n", (int) object.num);
+	    SelPtr list = 0;
+	    SelectObject(&list, object.num);
+	    DeleteVerticesJoinLineDefs(list);
+	    ForgetSelection(&list);
+	    RedrawMap = 1;
+	}
 
-   /* Clicking anywhere else closes the pull-down menus. */
-   else if (is.key == YE_BUTL_PRESS)
-      e.menubar->highlight (-1);  // Close any open menu
+	/* Clicking anywhere else closes the pull-down menus. */
+	else if (is.key == YE_BUTL_PRESS)
+	    e.menubar->highlight(-1);	// Close any open menu
 
-   /* Releasing the button while there was a selection box
-      causes all the objects within the box to be selected. */
-   // FIXME : should call this automatically when switching tool
-   else if (is.key == YE_BUTL_RELEASE
-	 && e.tool == TOOL_NORMAL
-	 && e.clicked == CANVAS)
-      {
-      int x1, y1, x2, y2;
-      e.selbox->get_corners (&x1, &y1, &x2, &y2);
-      SelectObjectsInBox (&e.Selected, e.obj_type, x1, y1, x2, y2);
-      e.selbox->unset_corners ();
-      RedrawMap = 1;
-      }
+	/* Releasing the button while there was a selection box
+	   causes all the objects within the box to be selected. */
+	// FIXME : should call this automatically when switching tool
+	else if (is.key == YE_BUTL_RELEASE
+		 && e.tool == TOOL_NORMAL && e.clicked == CANVAS)
+	{
+	    int x1, y1, x2, y2;
+	    e.selbox->get_corners(&x1, &y1, &x2, &y2);
+	    SelectObjectsInBox(&e.Selected, e.obj_type, x1, y1, x2, y2);
+	    e.selbox->unset_corners();
+	    RedrawMap = 1;
+	}
 
-   /* Releasing the button while dragging : drop the selection. */
-   // FIXME : should call this automatically when switching tool
-   else if (is.key == YE_BUTL_RELEASE
-	 && e.tool == TOOL_NORMAL
-	 && e.clicked ())
-      {
-      if (AutoMergeVertices (&e.Selected, e.obj_type, 'm'))
-         RedrawMap = 1;
-      }
+	/* Releasing the button while dragging : drop the selection. */
+	// FIXME : should call this automatically when switching tool
+	else if (is.key == YE_BUTL_RELEASE
+		 && e.tool == TOOL_NORMAL && e.clicked())
+	{
+	    if (AutoMergeVertices(&e.Selected, e.obj_type, 'm'))
+		RedrawMap = 1;
+	}
 
-   // Moving the pointer with the left button pressed
-   // after clicking on an item of the menu bar : pull
-   // down menus as the pointer passes over them.
-   else if (is.key == YE_MOTION
-      && e.tool == TOOL_NORMAL
-      && is.butl
-      && ! e.clicked () && ! (e.clicked == CANVAS))
-      {
-      int itemno = e.menubar->is_on_menubar_item (is.x, is.y);
-      if (itemno >= 0)
-         e.menubar->pull_down (itemno);
-      goto done;
-      }
+	// Moving the pointer with the left button pressed
+	// after clicking on an item of the menu bar : pull
+	// down menus as the pointer passes over them.
+	else if (is.key == YE_MOTION
+		 && e.tool == TOOL_NORMAL
+		 && is.butl && !e.clicked() && !(e.clicked == CANVAS))
+	{
+	    int itemno = e.menubar->is_on_menubar_item(is.x, is.y);
+	    if (itemno >= 0)
+		e.menubar->pull_down(itemno);
+	    goto done;
+	}
 
-   /* Moving the pointer with the left button pressed
-      and a selection box exists : move the second
-      corner of the selection box. */
-   else if ((is.key == YE_MOTION || motion)
-      && e.tool == TOOL_NORMAL
-      && is.butl && e.clicked == CANVAS)
-      {
-      e.selbox->set_2nd_corner (e.pointer_x, e.pointer_y);
-      }
+	/* Moving the pointer with the left button pressed
+	   and a selection box exists : move the second
+	   corner of the selection box. */
+	else if ((is.key == YE_MOTION || motion)
+		 && e.tool == TOOL_NORMAL && is.butl && e.clicked == CANVAS)
+	{
+	    e.selbox->set_2nd_corner(e.pointer_x, e.pointer_y);
+	}
 
-   /* Moving the pointer with the left button pressed
-      but no selection box exists and [Ctrl] was not
-      pressed when the button was pressed :
-      drag the selection. */
-   else if (motion
-      && e.tool == TOOL_NORMAL
-      && is.butl
-      && e.clicked ()
-      && ! e.click_ctrl)
-      {
-      if (! e.Selected)
-	 {
-	 SelectObject (&e.Selected, e.clicked.num);
-	 if (MoveObjectsToCoords (e.clicked.type, e.Selected,
-            e.pointer_x, e.pointer_y, e.grid_snap ? e.grid_step : 0))
-	    RedrawMap = 1;
-	 ForgetSelection (&e.Selected);
-	 }
-      else
-	 if (MoveObjectsToCoords (e.clicked.type, e.Selected,
-            e.pointer_x, e.pointer_y, e.grid_snap ? e.grid_step : 0))
-	    RedrawMap = 1;
-      }
+	/* Moving the pointer with the left button pressed
+	   but no selection box exists and [Ctrl] was not
+	   pressed when the button was pressed :
+	   drag the selection. */
+	else if (motion
+		 && e.tool == TOOL_NORMAL
+		 && is.butl && e.clicked() && !e.click_ctrl)
+	{
+	    if (!e.Selected)
+	    {
+		SelectObject(&e.Selected, e.clicked.num);
+		if (MoveObjectsToCoords(e.clicked.type, e.Selected,
+					e.pointer_x, e.pointer_y,
+					e.grid_snap ? e.grid_step : 0))
+		    RedrawMap = 1;
+		ForgetSelection(&e.Selected);
+	    }
+	    else if (MoveObjectsToCoords(e.clicked.type, e.Selected,
+					 e.pointer_x, e.pointer_y,
+					 e.grid_snap ? e.grid_step : 0))
+		RedrawMap = 1;
+	}
 
-   /* AYM : added is.in_window */
-   if (is.in_window && ! is.butl && ! is.shift)
-      {
-      /* Check if there is something near the pointer */
-      e.highlighted = object;
-      }
+	/* AYM : added is.in_window */
+	if (is.in_window && !is.butl && !is.shift)
+	{
+	    /* Check if there is something near the pointer */
+	    e.highlighted = object;
+	}
 
-   /*
-    *	Step 3.2.3 -- Keyboard events
-    */
+	/*
+	 *   Step 3.2.3 -- Keyboard events
+	 */
 
-   if (event_is_key (is.key)
-      || is.key == YE_WHEEL_UP
-      || is.key == YE_WHEEL_DOWN)
-      {
-      if (is.key == YK_LEFT && e.menubar->highlighted () >= 0)
-         {
-         int new_item = e.menubar->highlighted () - 1;
-         if (new_item < 0)
-            new_item = e.mb_ino[MBI_HELP];
-         e.menubar->pull_down (new_item);
-         RedrawMap = 1;
-         }
+	if (event_is_key(is.key)
+	    || is.key == YE_WHEEL_UP || is.key == YE_WHEEL_DOWN)
+	{
+	    if (is.key == YK_LEFT && e.menubar->highlighted() >= 0)
+	    {
+		int new_item = e.menubar->highlighted() - 1;
+		if (new_item < 0)
+		    new_item = e.mb_ino[MBI_HELP];
+		e.menubar->pull_down(new_item);
+		RedrawMap = 1;
+	    }
 
-      else if (is.key == YK_RIGHT && e.menubar->highlighted () >= 0)
-         {
-         int new_item = e.menubar->highlighted () + 1;
-         if (new_item > e.mb_ino[MBI_HELP])
-            new_item = 0;
-         e.menubar->pull_down (new_item);
-         RedrawMap = 1;
-         }
+	    else if (is.key == YK_RIGHT && e.menubar->highlighted() >= 0)
+	    {
+		int new_item = e.menubar->highlighted() + 1;
+		if (new_item > e.mb_ino[MBI_HELP])
+		    new_item = 0;
+		e.menubar->pull_down(new_item);
+		RedrawMap = 1;
+	    }
 
-      else if (is.key == YK_ALT + 'f')
-         e.menubar->pull_down (e.mb_ino[MBI_FILE]);
+	    else if (is.key == YK_ALT + 'f')
+		e.menubar->pull_down(e.mb_ino[MBI_FILE]);
 
-      else if (is.key == YK_ALT + 'e')
-         e.menubar->pull_down (e.mb_ino[MBI_EDIT]);
+	    else if (is.key == YK_ALT + 'e')
+		e.menubar->pull_down(e.mb_ino[MBI_EDIT]);
 
-      else if (is.key == YK_ALT + 's')
-	 e.menubar->pull_down (e.mb_ino[MBI_SEARCH]);
+	    else if (is.key == YK_ALT + 's')
+		e.menubar->pull_down(e.mb_ino[MBI_SEARCH]);
 
-      else if (is.key == YK_ALT + 'v')
-	 e.menubar->pull_down (e.mb_ino[MBI_VIEW]);
+	    else if (is.key == YK_ALT + 'v')
+		e.menubar->pull_down(e.mb_ino[MBI_VIEW]);
 
-      else if (is.key == YK_ALT + 'm')
-	 e.menubar->pull_down (e.mb_ino[MBI_MISC]);
+	    else if (is.key == YK_ALT + 'm')
+		e.menubar->pull_down(e.mb_ino[MBI_MISC]);
 
-      else if (is.key == YK_ALT + 'o')
-	 e.menubar->pull_down (e.mb_ino[MBI_OBJECTS]);
+	    else if (is.key == YK_ALT + 'o')
+		e.menubar->pull_down(e.mb_ino[MBI_OBJECTS]);
 
-      else if (is.key == YK_ALT + 'c')
-	 e.menubar->pull_down (e.mb_ino[MBI_CHECK]);
+	    else if (is.key == YK_ALT + 'c')
+		e.menubar->pull_down(e.mb_ino[MBI_CHECK]);
 
-      else if (is.key == YK_ALT + 'h')
-	 e.menubar->pull_down (e.mb_ino[MBI_HELP]);
+	    else if (is.key == YK_ALT + 'h')
+		e.menubar->pull_down(e.mb_ino[MBI_HELP]);
 
 
-      // [Ctrl][L]: force redraw
-      else if (is.key == '\f')
-	{
-	RedrawMap = 1;
-	}
-
-      // [Esc], [q]: close
-      else if (is.key == YK_ESC || is.key == 'q')
-         {
-	 if (DragObject)
-	    DragObject = false;
-	 else if (StretchSelBox)
-	    StretchSelBox = false;
-	 else
+	    // [Ctrl][L]: force redraw
+	    else if (is.key == '\f')
 	    {
-	    ForgetSelection (&e.Selected);
-	    if (!MadeChanges
-	     || Confirm (-1, -1, "You have unsaved changes."
-				" Do you really want to quit?", 0))
-	       break;
-	    RedrawMap = 1;
+		RedrawMap = 1;
 	    }
-         }
-
-      // [F1]: pop up "Help" window
-      else if (is.key == YK_F1) /* 'F1' */
-         {
-	 DisplayHelp ();
-	 RedrawMap = 1;
-         }
 
-      // [Alt][a]: pop up the "About..." window
-      else if (is.key == YK_ALT + 'a')
-         {
-         about_yadex ();
-         RedrawMap = 1;
-         }
-
-      // [Shift][F1]: save a screen shot into yadex.gif.
-      // FIXME doesn't work in the Unix port
-      else if (is.key == YK_F1 + YK_SHIFT)
-	 {
-	 Rgbbmp b;
-	 window_to_rgbbmp (0, 0, (int) ScrMaxX + 1, (int) ScrMaxY + 1, b);
-	 rgbbmp_to_rawppm (b, "yadex.ppm");
-	 //ScreenShot ();
-	 }
+	    // [Esc], [q]: close
+	    else if (is.key == YK_ESC || is.key == 'q')
+	    {
+		if (DragObject)
+		    DragObject = false;
+		else if (StretchSelBox)
+		    StretchSelBox = false;
+		else
+		{
+		    ForgetSelection(&e.Selected);
+		    if (!MadeChanges
+			|| Confirm(-1, -1, "You have unsaved changes."
+				   " Do you really want to quit?", 0))
+			break;
+		    RedrawMap = 1;
+		}
+	    }
 
-      // [Shift][F2]: undocumented--test of Entry2
-      else if (is.key == YK_F2 + YK_SHIFT)
-	 {
-	 char buf1[10];
-	 char buf2[30];
-	 char buf3[20];
-	 strcpy (buf1, "buf1");
-	 strcpy (buf2, "buf2");
-	 strcpy (buf3, "buf3");
-	 Entry2 e ("Title of window", "Buf 1%*sBuf 2%*sBuf 3%*s",
-	     sizeof buf1 - 1, buf1,
-	     sizeof buf2 - 1, buf2,
-	     sizeof buf3 - 1, buf3);
-	 e.loop ();
-	 printf ("bufs: \"%s\", \"%s\", \"%s\"\n", buf1, buf2, buf3);
-	 RedrawMap = 1;
-	 }
+	    // [F1]: pop up "Help" window
+	    else if (is.key == YK_F1)	/* 'F1' */
+	    {
+		DisplayHelp();
+		RedrawMap = 1;
+	    }
+
+	    // [Alt][a]: pop up the "About..." window
+	    else if (is.key == YK_ALT + 'a')
+	    {
+		about_yadex();
+		RedrawMap = 1;
+	    }
 
-      /* [F2] save level into pwad, prompt for the file name
-         every time but keep the same level name. */
-      else if (is.key == YK_F2 && Registered)
-         {
-	 if (! CheckStartingPos ())
-	    goto cancel_save;
-	 char *outfile;
-	 const char *newlevelname;
-	 if (levelname)
-	    newlevelname = levelname;
-	 else
+	    // [Shift][F1]: save a screen shot into yadex.gif.
+	    // FIXME doesn't work in the Unix port
+	    else if (is.key == YK_F1 + YK_SHIFT)
 	    {
-	    newlevelname = SelectLevel (0);
-	    if (! *newlevelname)
-	       goto cancel_save;
+		Rgbbmp b;
+		window_to_rgbbmp(0, 0, (int) ScrMaxX + 1, (int) ScrMaxY + 1,
+				 b);
+		rgbbmp_to_rawppm(b, "yadex.ppm");
+		//ScreenShot ();
 	    }
-	 outfile = GetWadFileName (newlevelname);
-	 if (! outfile)
-	    goto cancel_save;
-	 SaveLevelData (outfile, newlevelname);
-	 levelname = newlevelname;
-	 // Sigh. Shouldn't have to do that. Level must die !
-	 Level = FindMasterDir (MasterDir, levelname);
-cancel_save:
-	 RedrawMap = 1;
-         }
 
-      /* [F3] save level into pwad, prompt for the file name and
-         level name. */
-      else if (is.key == YK_F3 && Registered)
-         {
-	 char *outfile;
-	 const char *newlevelname;
-	 MDirPtr newLevel, oldl, newl;
+	    // [Shift][F2]: undocumented--test of Entry2
+	    else if (is.key == YK_F2 + YK_SHIFT)
+	    {
+		char buf1[10];
+		char buf2[30];
+		char buf3[20];
+		strcpy(buf1, "buf1");
+		strcpy(buf2, "buf2");
+		strcpy(buf3, "buf3");
+		Entry2 e("Title of window", "Buf 1%*sBuf 2%*sBuf 3%*s",
+			 sizeof buf1 - 1, buf1,
+			 sizeof buf2 - 1, buf2, sizeof buf3 - 1, buf3);
+		e.loop();
+		printf("bufs: \"%s\", \"%s\", \"%s\"\n", buf1, buf2, buf3);
+		RedrawMap = 1;
+	    }
 
-	 if (! CheckStartingPos ())
-	    goto cancel_save_as;
-	 newlevelname = SelectLevel (0);
-	 if (! *newlevelname)
-	    goto cancel_save_as;
-	 if (! levelname || y_stricmp (newlevelname, levelname))
+	    /* [F2] save level into pwad, prompt for the file name
+	       every time but keep the same level name. */
+	    else if (is.key == YK_F2 && Registered)
 	    {
-	    /* horrible but it works... */
-	    // Horrible indeed -- AYM 1999-07-30
-	    newLevel = FindMasterDir (MasterDir, newlevelname);
-	    if (! newLevel)
-	       nf_bug ("newLevel is NULL");  // Debatable ! -- AYM 2001-05-29
-	    if (Level)  // If new level ("create" command), Level is NULL
-	       {
-	       oldl = Level;
-	       newl = newLevel;
-	       for (int m = 0; m < 11; m++)
-		  {
-		  newl->wadfile = oldl->wadfile;
-		  if (m > 0)
-		     newl->dir = oldl->dir;
-		  /*
-		  if (!fncmp (outfile, oldl->wadfile->filename))
-		     {
-		     oldl->wadfile = WadFileList;
-		     oldl->dir = lost...
-		     }
-		  */
-		  oldl = oldl->next;
-		  newl = newl->next;
-		  }
-	       }
-	    Level = newLevel;
+		if (!CheckStartingPos())
+		    goto cancel_save;
+		char *outfile;
+		const char *newlevelname;
+		if (levelname)
+		    newlevelname = levelname;
+		else
+		{
+		    newlevelname = SelectLevel(0);
+		    if (!*newlevelname)
+			goto cancel_save;
+		}
+		outfile = GetWadFileName(newlevelname);
+		if (!outfile)
+		    goto cancel_save;
+		SaveLevelData(outfile, newlevelname);
+		levelname = newlevelname;
+		// Sigh. Shouldn't have to do that. Level must die !
+		Level = FindMasterDir(MasterDir, levelname);
+	      cancel_save:
+		RedrawMap = 1;
 	    }
-	 outfile = GetWadFileName (newlevelname);
-	 if (! outfile)
-	    goto cancel_save_as;
-	 SaveLevelData (outfile, newlevelname);
-	 levelname = newlevelname;
-cancel_save_as:
-	 RedrawMap = 1;
-         }
 
-      // [F5]: pop up the "Preferences" menu
-      else if (is.key == YK_F5
-         && e.menubar->highlighted () < 0)
-         {
-	 Preferences (-1, -1);
-	 RedrawMap = 1;
-         }
-
-      // [a]: pop up the "Set flag" menu
-      else if (is.key == 'a'
-         && e.menubar->highlighted () < 0
-         && (e.Selected || e.highlighted ()))
-         {
-         e.modal = 's';  // Set
-         if (e.obj_type == OBJ_LINEDEFS)
-            {
-            menu_linedef_flags->set_title ("Set linedef flag");
-            e.modpopup->set (menu_linedef_flags, 0);
-            }
-         else if (e.obj_type == OBJ_THINGS)
-            {
-            menu_thing_flags->set_title ("Set thing flag");
-            e.modpopup->set (menu_thing_flags, 0);
-            }
-         }
+	    /* [F3] save level into pwad, prompt for the file name and
+	       level name. */
+	    else if (is.key == YK_F3 && Registered)
+	    {
+		char *outfile;
+		const char *newlevelname;
+		MDirPtr newLevel, oldl, newl;
 
-      // [b]: pop up the "Toggle flag" menu
-      else if (is.key == 'b'
-         && e.menubar->highlighted () < 0
-         && (e.Selected || e.highlighted ()))
-         {
-         e.modal = 't';  // Toggle
-         if (e.obj_type == OBJ_LINEDEFS)
-            {
-            menu_linedef_flags->set_title ("Toggle linedef flag");
-            e.modpopup->set (menu_linedef_flags, 0);
-            }
-         else if (e.obj_type == OBJ_THINGS)
-            {
-            menu_thing_flags->set_title ("Toggle thing flag");
-            e.modpopup->set (menu_thing_flags, 0);
-            }
-         }
+		if (!CheckStartingPos())
+		    goto cancel_save_as;
+		newlevelname = SelectLevel(0);
+		if (!*newlevelname)
+		    goto cancel_save_as;
+		if (!levelname || y_stricmp(newlevelname, levelname))
+		{
+		    /* horrible but it works... */
+		    // Horrible indeed -- AYM 1999-07-30
+		    newLevel = FindMasterDir(MasterDir, newlevelname);
+		    if (!newLevel)
+			nf_bug("newLevel is NULL");	// Debatable ! -- AYM 2001-05-29
+		    if (Level)	// If new level ("create" command), Level is NULL
+		    {
+			oldl = Level;
+			newl = newLevel;
+			for (int m = 0; m < 11; m++)
+			{
+			    newl->wadfile = oldl->wadfile;
+			    if (m > 0)
+				newl->dir = oldl->dir;
+			    /*
+			       if (!fncmp (outfile, oldl->wadfile->filename))
+			       {
+			       oldl->wadfile = WadFileList;
+			       oldl->dir = lost...
+			       }
+			     */
+			    oldl = oldl->next;
+			    newl = newl->next;
+			}
+		    }
+		    Level = newLevel;
+		}
+		outfile = GetWadFileName(newlevelname);
+		if (!outfile)
+		    goto cancel_save_as;
+		SaveLevelData(outfile, newlevelname);
+		levelname = newlevelname;
+	      cancel_save_as:
+		RedrawMap = 1;
+	    }
 
-      // [c]: pop up the "Clear flag" menu
-      else if (is.key == 'c'
-         && e.menubar->highlighted () < 0
-         && (e.Selected || e.highlighted ()))
-         {
-         e.modal = 'c';  // Clear;
-         if (e.obj_type == OBJ_LINEDEFS)
-            {
-            menu_linedef_flags->set_title ("Clear linedef flag");
-            e.modpopup->set (menu_linedef_flags, 0);
-            }
-         else if (e.obj_type == OBJ_THINGS)
-            {
-            menu_thing_flags->set_title ("Clear thing flag");
-            e.modpopup->set (menu_thing_flags, 0);
-            }
-         }
+	    // [F5]: pop up the "Preferences" menu
+	    else if (is.key == YK_F5 && e.menubar->highlighted() < 0)
+	    {
+		Preferences(-1, -1);
+		RedrawMap = 1;
+	    }
+
+	    // [a]: pop up the "Set flag" menu
+	    else if (is.key == 'a'
+		     && e.menubar->highlighted() < 0
+		     && (e.Selected || e.highlighted()))
+	    {
+		e.modal = 's';	// Set
+		if (e.obj_type == OBJ_LINEDEFS)
+		{
+		    menu_linedef_flags->set_title("Set linedef flag");
+		    e.modpopup->set(menu_linedef_flags, 0);
+		}
+		else if (e.obj_type == OBJ_THINGS)
+		{
+		    menu_thing_flags->set_title("Set thing flag");
+		    e.modpopup->set(menu_thing_flags, 0);
+		}
+	    }
 
-      // [F8]: pop up the "Misc. operations" menu
-      else if (is.key == YK_F8
-         && e.menubar->highlighted () < 0)
-         {
-         e.modpopup->set (e.menubar->get_menu (MBI_MISC), 1);
-         }
-
-      // [F9]: pop up the "Insert a standard object" menu
-      else if (is.key == YK_F9
-         && e.menubar->highlighted () < 0)
-         {
-         e.modpopup->set (e.menubar->get_menu (MBI_OBJECTS), 1);
-         }
+	    // [b]: pop up the "Toggle flag" menu
+	    else if (is.key == 'b'
+		     && e.menubar->highlighted() < 0
+		     && (e.Selected || e.highlighted()))
+	    {
+		e.modal = 't';	// Toggle
+		if (e.obj_type == OBJ_LINEDEFS)
+		{
+		    menu_linedef_flags->set_title("Toggle linedef flag");
+		    e.modpopup->set(menu_linedef_flags, 0);
+		}
+		else if (e.obj_type == OBJ_THINGS)
+		{
+		    menu_thing_flags->set_title("Toggle thing flag");
+		    e.modpopup->set(menu_thing_flags, 0);
+		}
+	    }
 
-      // [F10]: pop up the "Checks" menu
-      else if (is.key == YK_F10
-         && e.menubar->highlighted () < 0)
-         {
-	 CheckLevel (-1, -1);
-	 RedrawMap = 1;
-         }
+	    // [c]: pop up the "Clear flag" menu
+	    else if (is.key == 'c'
+		     && e.menubar->highlighted() < 0
+		     && (e.Selected || e.highlighted()))
+	    {
+		e.modal = 'c';	// Clear;
+		if (e.obj_type == OBJ_LINEDEFS)
+		{
+		    menu_linedef_flags->set_title("Clear linedef flag");
+		    e.modpopup->set(menu_linedef_flags, 0);
+		}
+		else if (e.obj_type == OBJ_THINGS)
+		{
+		    menu_thing_flags->set_title("Clear thing flag");
+		    e.modpopup->set(menu_thing_flags, 0);
+		}
+	    }
 
-      // [Alt][i]: show/hide the info bar
-      else if (is.key == YK_ALT + 'i')
-         {
-	 e.infobar_shown = !e.infobar_shown;
-	 RedrawMap = 1;
-         }
+	    // [F8]: pop up the "Misc. operations" menu
+	    else if (is.key == YK_F8 && e.menubar->highlighted() < 0)
+	    {
+		e.modpopup->set(e.menubar->get_menu(MBI_MISC), 1);
+	    }
 
-      // [i]: show/hide the object info boxes
-      else if (is.key == 'i')
-         {
-	 e.objinfo_shown = !e.objinfo_shown;
-	 RedrawMap = 1;
-	 }
+	    // [F9]: pop up the "Insert a standard object" menu
+	    else if (is.key == YK_F9 && e.menubar->highlighted() < 0)
+	    {
+		e.modpopup->set(e.menubar->get_menu(MBI_OBJECTS), 1);
+	    }
+
+	    // [F10]: pop up the "Checks" menu
+	    else if (is.key == YK_F10 && e.menubar->highlighted() < 0)
+	    {
+		CheckLevel(-1, -1);
+		RedrawMap = 1;
+	    }
 
-      // [+], [=], wheel: zooming in
-      else if (is.key == '+' || is.key == '=' || is.key == YE_WHEEL_UP)
-         {
-         int r = edit_zoom_in (&e);
-	 if (r == 0)
-	   RedrawMap = 1;
-         }
+	    // [Alt][i]: show/hide the info bar
+	    else if (is.key == YK_ALT + 'i')
+	    {
+		e.infobar_shown = !e.infobar_shown;
+		RedrawMap = 1;
+	    }
 
-      // [-], [_], wheel: zooming out
-      else if (is.key == '-' || is.key == '_' || is.key == YE_WHEEL_DOWN)
-         {
-         int r = edit_zoom_out (&e);
-	 if (r == 0)
-	   RedrawMap = 1;
-         }
+	    // [i]: show/hide the object info boxes
+	    else if (is.key == 'i')
+	    {
+		e.objinfo_shown = !e.objinfo_shown;
+		RedrawMap = 1;
+	    }
+
+	    // [+], [=], wheel: zooming in
+	    else if (is.key == '+' || is.key == '=' || is.key == YE_WHEEL_UP)
+	    {
+		int r = edit_zoom_in(&e);
+		if (r == 0)
+		    RedrawMap = 1;
+	    }
 
-      // [1] - [9], [0]: set the zoom factor
-      else if (is.key >= '0' && is.key <= '9')
-         {
-         int r = edit_set_zoom (&e, digit_zoom_factors[dectoi(is.key)]);
-	 if (r == 0)
-	   RedrawMap = 1;
-         }
+	    // [-], [_], wheel: zooming out
+	    else if (is.key == '-' || is.key == '_'
+		     || is.key == YE_WHEEL_DOWN)
+	    {
+		int r = edit_zoom_out(&e);
+		if (r == 0)
+		    RedrawMap = 1;
+	    }
+
+	    // [1] - [9], [0]: set the zoom factor
+	    else if (is.key >= '0' && is.key <= '9')
+	    {
+		int r = edit_set_zoom(&e, digit_zoom_factors[dectoi(is.key)]);
+		if (r == 0)
+		    RedrawMap = 1;
+	    }
 
-      // [']: centre window on centre of map
-      else if (is.key == '\'')
-         {
-	 update_level_bounds ();
-         CenterMapAroundCoords ((MapMinX + MapMaxX) / 2,
-            (MapMinY + MapMaxY) / 2);
-         RedrawMap = 1;
-         }
+	    // [']: centre window on centre of map
+	    else if (is.key == '\'')
+	    {
+		update_level_bounds();
+		CenterMapAroundCoords((MapMinX + MapMaxX) / 2,
+				      (MapMinY + MapMaxY) / 2);
+		RedrawMap = 1;
+	    }
 
-      // [`]: centre window on centre of map
-      // and set zoom to view the entire map
-      else if (is.key == '`')
-         {
-	 int r = zoom_fit (e);
-	 if (r == 0)
-	   RedrawMap = 1;
-         }
+	    // [`]: centre window on centre of map
+	    // and set zoom to view the entire map
+	    else if (is.key == '`')
+	    {
+		int r = zoom_fit(e);
+		if (r == 0)
+		    RedrawMap = 1;
+	    }
 
 
-      // [Left], [Right], [Up], [Down]:
-      // scroll <scroll_less> percents of a screenful.
-      else if (is.key == YK_LEFT && MAPX (ScrCenterX) > -20000)
-         {
-	 OrigX -= (int) ((double) ScrMaxX * scroll_less / 100 / Scale);
-	 RedrawMap = 1;
-	 }
-      else if (is.key == YK_RIGHT && MAPX (ScrCenterX) < 20000)
-         {
-	 OrigX += (int) ((double) ScrMaxX * scroll_less / 100 / Scale);
-	 RedrawMap = 1;
-	 }
-      else if (is.key == YK_UP && MAPY (ScrCenterY) < 20000)
-         {
-	 OrigY += (int) ((double) ScrMaxY * scroll_less / 100 / Scale);
-	 RedrawMap = 1;
-	 }
-      else if (is.key == YK_DOWN && MAPY (ScrCenterY) > -20000)
-         {
-	 OrigY -= (int) ((double) ScrMaxY * scroll_less / 100 / Scale);
-	 RedrawMap = 1;
-	 }
+	    // [Left], [Right], [Up], [Down]:
+	    // scroll <scroll_less> percents of a screenful.
+	    else if (is.key == YK_LEFT && MAPX(ScrCenterX) > -20000)
+	    {
+		OrigX -= (int) ((double) ScrMaxX * scroll_less / 100 / Scale);
+		RedrawMap = 1;
+	    }
+	    else if (is.key == YK_RIGHT && MAPX(ScrCenterX) < 20000)
+	    {
+		OrigX += (int) ((double) ScrMaxX * scroll_less / 100 / Scale);
+		RedrawMap = 1;
+	    }
+	    else if (is.key == YK_UP && MAPY(ScrCenterY) < 20000)
+	    {
+		OrigY += (int) ((double) ScrMaxY * scroll_less / 100 / Scale);
+		RedrawMap = 1;
+	    }
+	    else if (is.key == YK_DOWN && MAPY(ScrCenterY) > -20000)
+	    {
+		OrigY -= (int) ((double) ScrMaxY * scroll_less / 100 / Scale);
+		RedrawMap = 1;
+	    }
+
+	    // [Pgup], [Pgdn], [Home], [End]:
+	    // scroll <scroll_more> percents of a screenful.
+	    else if (is.key == YK_PU && MAPY(ScrCenterY) < /*MapMaxY */ 20000)
+	    {
+		OrigY += (int) ((double) ScrMaxY * scroll_more / 100 / Scale);
+		RedrawMap = 1;
+	    }
+	    else if (is.key == YK_PD
+		     && MAPY(ScrCenterY) > /*MapMinY */ -20000)
+	    {
+		OrigY -= (int) ((double) ScrMaxY * scroll_more / 100 / Scale);
+		RedrawMap = 1;
+	    }
+	    else if (is.key == YK_HOME
+		     && MAPX(ScrCenterX) > /*MapMinX */ -20000)
+	    {
+		OrigX -= (int) ((double) ScrMaxX * scroll_more / 100 / Scale);
+		RedrawMap = 1;
+	    }
+	    else if (is.key == YK_END
+		     && MAPX(ScrCenterX) < /*MapMaxX */ 20000)
+	    {
+		OrigX += (int) ((double) ScrMaxX * scroll_more / 100 / Scale);
+		RedrawMap = 1;
+	    }
+
+	    else if (is.key == ' ')
+	    {
+		e.extra_zoom = !e.extra_zoom;
+		edit_set_zoom(&e, Scale * (e.extra_zoom ? 4 : 0.25));
+		RedrawMap = 1;
+	    }
+
+	    // [Tab], [l], [s], [t], [v]: switch mode
+	    else if (is.key == YK_TAB || is.key == YK_BACKTAB
+		     || is.key == 't' || is.key == 'v' || is.key == 'l'
+		     || is.key == 's')
+	    {
+		int old_mode;
+		int new_mode = -1;
+		int PrevMode = e.obj_type;
+		SelPtr NewSel;
+
+		// What's the number of the current mode ?
+		old_mode = obj_type_to_mode_no(e.obj_type);
+
+		// What's the number of the new mode ?
+		if (is.key == YK_TAB)	// [Tab]
+		    new_mode = (old_mode + 1) % NB_MODES;
+		else if (is.key == YK_BACKTAB)	// [Shift]-[Tab]
+		    new_mode = old_mode == 0 ? NB_MODES - 1 : old_mode - 1;
+		else
+		{
+		    if (is.key == 't')
+			new_mode = obj_type_to_mode_no(OBJ_THINGS);
+		    else if (is.key == 'v')
+			new_mode = obj_type_to_mode_no(OBJ_VERTICES);
+		    else if (is.key == 'l')
+			new_mode = obj_type_to_mode_no(OBJ_LINEDEFS);
+		    else if (is.key == 's')
+			new_mode = obj_type_to_mode_no(OBJ_SECTORS);
+		    else
+			fatal_error("changing mode with %04X", is.key);
+		    /* unselect all */
+		    ForgetSelection(&e.Selected);
+		}
+
+		// Set the object type according to the new mode.
+		e.obj_type = modes[new_mode].obj_type;
+
+		// Change the flavour of the "Misc" menu.
+		e.menubar->set_menu(e.mb_ino[MBI_MISC],
+				    e.mb_menu[modes[new_mode].menu_no]);
 
-      // [Pgup], [Pgdn], [Home], [End]:
-      // scroll <scroll_more> percents of a screenful.
-      else if (is.key == YK_PU && MAPY (ScrCenterY) < /*MapMaxY*/ 20000)
-	 {
-	 OrigY += (int) ((double) ScrMaxY * scroll_more / 100 / Scale);
-	 RedrawMap = 1;
-	 }
-      else if (is.key == YK_PD && MAPY (ScrCenterY) > /*MapMinY*/ -20000)
-	 {
-	 OrigY -= (int) ((double) ScrMaxY * scroll_more / 100 / Scale);
-	 RedrawMap = 1;
-	 }
-      else if (is.key == YK_HOME && MAPX (ScrCenterX) > /*MapMinX*/ -20000)
-	 {
-	 OrigX -= (int) ((double) ScrMaxX * scroll_more / 100 / Scale);
-	 RedrawMap = 1;
-	 }
-      else if (is.key == YK_END && MAPX (ScrCenterX) < /*MapMaxX*/ 20000)
-	 {
-	 OrigX += (int) ((double) ScrMaxX * scroll_more / 100 / Scale);
-	 RedrawMap = 1;
-	 }
-
-      else if (is.key == ' ')
-         {
-         e.extra_zoom = ! e.extra_zoom;
-         edit_set_zoom (&e, Scale * (e.extra_zoom ? 4 : 0.25));
-         RedrawMap = 1;
-         }
+		/* special cases for the selection list... */
+		if (e.Selected)
+		{
+		    /* select all linedefs bound to the selected sectors */
+		    if (PrevMode == OBJ_SECTORS && e.obj_type == OBJ_LINEDEFS)
+		    {
+			int l, sd;
 
-      // [Tab], [l], [s], [t], [v]: switch mode
-      else if (is.key == YK_TAB || is.key == YK_BACKTAB
-       || is.key == 't' || is.key == 'v' || is.key == 'l' || is.key == 's')
-	 {
-         int    old_mode;
-         int    new_mode = -1;
-	 int    PrevMode = e.obj_type;
-	 SelPtr NewSel;
-
-         // What's the number of the current mode ?
-         old_mode = obj_type_to_mode_no (e.obj_type);
+			NewSel = 0;
+			for (l = 0; l < NumLineDefs; l++)
+			{
+			    sd = LineDefs[l].sidedef1;
+			    if (sd >= 0
+				&& IsSelected(e.Selected,
+					      SideDefs[sd].sector))
+				SelectObject(&NewSel, l);
+			    else
+			    {
+				sd = LineDefs[l].sidedef2;
+				if (sd >= 0
+				    && IsSelected(e.Selected,
+						  SideDefs[sd].sector))
+				    SelectObject(&NewSel, l);
+			    }
+			}
+			ForgetSelection(&e.Selected);
+			e.Selected = NewSel;
+		    }
+		    /* select all Vertices bound to the selected linedefs */
+		    else if (PrevMode == OBJ_LINEDEFS
+			     && e.obj_type == OBJ_VERTICES)
+		    {
+			NewSel = 0;
+			while (e.Selected)
+			{
+			    if (!IsSelected
+				(NewSel, LineDefs[e.Selected->objnum].start))
+				SelectObject(&NewSel,
+					     LineDefs[e.Selected->objnum].
+					     start);
+			    if (!IsSelected
+				(NewSel, LineDefs[e.Selected->objnum].end))
+				SelectObject(&NewSel,
+					     LineDefs[e.Selected->objnum].
+					     end);
+			    UnSelectObject(&e.Selected, e.Selected->objnum);
+			}
+			e.Selected = NewSel;
+		    }
+		    /* select all sectors that have their linedefs selected */
+		    else if (PrevMode == OBJ_LINEDEFS
+			     && e.obj_type == OBJ_SECTORS)
+		    {
+			int l, sd;
 
-         // What's the number of the new mode ?
-	 if (is.key == YK_TAB)				// [Tab]
-            new_mode = (old_mode + 1) % NB_MODES;
-	 else if (is.key == YK_BACKTAB)			// [Shift]-[Tab]
-            new_mode = old_mode == 0 ? NB_MODES - 1 : old_mode - 1;
-	 else
-	    {
-	    if (is.key == 't')
-	       new_mode = obj_type_to_mode_no (OBJ_THINGS);
-	    else if (is.key == 'v')
-	       new_mode = obj_type_to_mode_no (OBJ_VERTICES);
-	    else if (is.key == 'l')
-	       new_mode = obj_type_to_mode_no (OBJ_LINEDEFS);
-	    else if (is.key == 's')
-	       new_mode = obj_type_to_mode_no (OBJ_SECTORS);
-            else
-               fatal_error ("changing mode with %04X", is.key);
-	    /* unselect all */
-	    ForgetSelection (&e.Selected);
+			NewSel = 0;
+			/* select all sectors... */
+			for (l = 0; l < NumSectors; l++)
+			    SelectObject(&NewSel, l);
+			/* ... then unselect those that should not be in the list */
+			for (l = 0; l < NumLineDefs; l++)
+			    if (!IsSelected(e.Selected, l))
+			    {
+				sd = LineDefs[l].sidedef1;
+				if (sd >= 0)
+				    UnSelectObject(&NewSel,
+						   SideDefs[sd].sector);
+				sd = LineDefs[l].sidedef2;
+				if (sd >= 0)
+				    UnSelectObject(&NewSel,
+						   SideDefs[sd].sector);
+			    }
+			ForgetSelection(&e.Selected);
+			e.Selected = NewSel;
+		    }
+		    /* select all linedefs that have both ends selected */
+		    else if (PrevMode == OBJ_VERTICES
+			     && e.obj_type == OBJ_LINEDEFS)
+		    {
+			int l;
+
+			NewSel = 0;
+			for (l = 0; l < NumLineDefs; l++)
+			    if (IsSelected(e.Selected, LineDefs[l].start)
+				&& IsSelected(e.Selected, LineDefs[l].end))
+				SelectObject(&NewSel, l);
+			ForgetSelection(&e.Selected);
+			e.Selected = NewSel;
+		    }
+		    /* unselect all */
+		    else
+			ForgetSelection(&e.Selected);
+		}
+		if (GetMaxObjectNum(e.obj_type) >= 0 && Select0 && !e.global)
+		{
+		    e.highlighted.type = e.obj_type;
+		    e.highlighted.num = 0;
+		}
+		else
+		    e.highlighted.nil();
+
+		DragObject = false;
+		StretchSelBox = false;
+		RedrawMap = 1;
 	    }
 
-         // Set the object type according to the new mode.
-         e.obj_type = modes[new_mode].obj_type;
-
-         // Change the flavour of the "Misc" menu.
-         e.menubar->set_menu (e.mb_ino[MBI_MISC],
-            e.mb_menu[modes[new_mode].menu_no]);
-
-	 /* special cases for the selection list... */
-	 if (e.Selected)
+	    // [Ctrl][g]: toggle global mode
+	    else if (is.key == '\7')
 	    {
-	    /* select all linedefs bound to the selected sectors */
-	    if (PrevMode == OBJ_SECTORS && e.obj_type == OBJ_LINEDEFS)
-	       {
-	       int l, sd;
-
-	       NewSel = 0;
-	       for (l = 0; l < NumLineDefs; l++)
-	          {
-		  sd = LineDefs[l].sidedef1;
-		  if (sd >= 0 && IsSelected (e.Selected, SideDefs[sd].sector))
-		     SelectObject (&NewSel, l);
-		  else
-		     {
-		     sd = LineDefs[l].sidedef2;
-		     if (sd >= 0 && IsSelected (e.Selected, SideDefs[sd].sector))
-			SelectObject (&NewSel, l);
-		     }
-	          }
-	       ForgetSelection (&e.Selected);
-	       e.Selected = NewSel;
+		static bool dont_warn = false;
+		bool ok = false;
+		if (e.global)
+		    ok = true;	// No confirmation needed to switch off
+		else if (dont_warn)
+		    ok = true;
+		else
+		{
+		    ok = Confirm(-1, -1,
+				 "Global mode is experimental and probably highly",
+				 "unstable. This means crashes. Are you sure ?");
+		    RedrawMap = 1;
+		    if (ok)
+		    {
+			dont_warn = true;	// User is sure. Won't ask again
+			Notify(-1, -1,
+			       "Selection does not work in global mode. Don't",
+			       "bother reporting it, I'm aware of it already.");
+		    }
+		}
+		if (ok)
+		{
+		    ForgetSelection(&e.Selected);
+		    e.global = !e.global;
+		    RedrawMap = 1;
+		}
 	    }
-	    /* select all Vertices bound to the selected linedefs */
-	    else if (PrevMode == OBJ_LINEDEFS && e.obj_type == OBJ_VERTICES)
-	       {
-	       NewSel = 0;
-	       while (e.Selected)
-	          {
-		  if (!IsSelected (NewSel, LineDefs[e.Selected->objnum].start))
-		     SelectObject (&NewSel, LineDefs[e.Selected->objnum].start);
-		  if (!IsSelected (NewSel, LineDefs[e.Selected->objnum].end))
-		     SelectObject (&NewSel, LineDefs[e.Selected->objnum].end);
-		  UnSelectObject (&e.Selected, e.Selected->objnum);
-	          }
-	       e.Selected = NewSel;
-	       }
-	    /* select all sectors that have their linedefs selected */
-	    else if (PrevMode == OBJ_LINEDEFS && e.obj_type == OBJ_SECTORS)
-	       {
-	       int l, sd;
 
-	       NewSel = 0;
-	       /* select all sectors... */
-	       for (l = 0; l < NumSectors; l++)
-		  SelectObject (&NewSel, l);
-	       /* ... then unselect those that should not be in the list */
-	       for (l = 0; l < NumLineDefs; l++)
-		  if (!IsSelected (e.Selected, l))
-		     {
-		     sd = LineDefs[l].sidedef1;
-		     if (sd >= 0)
-			UnSelectObject (&NewSel, SideDefs[sd].sector);
-		     sd = LineDefs[l].sidedef2;
-		     if (sd >= 0)
-		       UnSelectObject (&NewSel, SideDefs[sd].sector);
-		     }
-	       ForgetSelection (&e.Selected);
-	       e.Selected = NewSel;
-	       }
-	    /* select all linedefs that have both ends selected */
-	    else if (PrevMode == OBJ_VERTICES && e.obj_type == OBJ_LINEDEFS)
-	       {
-	       int l;
+	    // [e]: Select/unselect all linedefs in non-forked path
+	    else if (is.key == 'e' && e.highlighted._is_linedef())
+	    {
+		ForgetSelection(&e.Selected);
+		select_linedefs_path(&e.Selected, e.highlighted.num, YS_ADD);
+		RedrawMap = 1;
+	    }
 
-	       NewSel = 0;
-	       for (l = 0; l < NumLineDefs; l++)
-		  if (IsSelected (e.Selected, LineDefs[l].start)
-		   && IsSelected (e.Selected, LineDefs[l].end))
-		     SelectObject (&NewSel, l);
-	       ForgetSelection (&e.Selected);
-	       e.Selected = NewSel;
-	       }
-	    /* unselect all */
-	    else
-	       ForgetSelection (&e.Selected);
+	    // [Ctrl][e] Select/unselect all linedefs in path
+	    else if (is.key == '\5' && !is.shift
+		     && e.highlighted._is_linedef())
+	    {
+		select_linedefs_path(&e.Selected, e.highlighted.num,
+				     YS_TOGGLE);
+		RedrawMap = 1;
+	    }
+	    // [E]: add linedef and split sector -- [AJA]
+	    else if (is.key == 'E' && e.obj_type == OBJ_VERTICES)
+	    {
+		if (e.Selected)
+		{
+		    MiscOperations(e.obj_type, &e.Selected, 5);
+		    RedrawMap = 1;
+		}
 	    }
-	 if (GetMaxObjectNum (e.obj_type) >= 0 && Select0 && ! e.global)
-	 {
-	    e.highlighted.type = e.obj_type;
-	    e.highlighted.num  = 0;
-	 }
-	 else
-	    e.highlighted.nil ();
+	    // [E]: Select/unselect all 1s linedefs in path
+	    else if (is.key == 'E' && e.highlighted._is_linedef())
+	    {
+		ForgetSelection(&e.Selected);
+		select_1s_linedefs_path(&e.Selected, e.highlighted.num,
+					YS_ADD);
+		RedrawMap = 1;
+	    }
 
-	 DragObject = false;
-	 StretchSelBox = false;
-	 RedrawMap = 1;
-	 }
+	    // [Ctrl][Shift][e]: Select/unselect all 1s linedefs in path
+	    else if (is.key == '\5' && is.shift
+		     && e.highlighted._is_linedef())
+	    {
+		select_1s_linedefs_path(&e.Selected, e.highlighted.num,
+					YS_TOGGLE);
+		RedrawMap = 1;
+	    }
 
-      // [Ctrl][g]: toggle global mode
-      else if (is.key == '\7')
-	 {
-	 static bool dont_warn = false;
-	 bool        ok        = false;
-	 if (e.global)
-	    ok = true;  // No confirmation needed to switch off
-	 else if (dont_warn)
-	    ok = true;
-	 else
+	    // [G]: to increase the grid step
+	    else if (is.key == 'G')
 	    {
-	    ok = Confirm (-1, -1,
-			  "Global mode is experimental and probably highly",
-			  "unstable. This means crashes. Are you sure ?");
-	    RedrawMap = 1;
-	    if (ok)
-	       {
-	       dont_warn = true;  // User is sure. Won't ask again
-	       Notify (-1, -1,
-		   "Selection does not work in global mode. Don't",
-		   "bother reporting it, I'm aware of it already.");
-	       }
+		if (e.grid_step < e.grid_step_max)
+		    e.grid_step *= 2;
+		else
+		    e.grid_step = e.grid_step_min;
+		RedrawMap = 1;
 	    }
-	 if (ok)
+
+	    // [g]: decrease the grid step
+	    else if (is.key == 'g')
 	    {
-	    ForgetSelection (&e.Selected);
-	    e.global = ! e.global;
-	    RedrawMap = 1;
+		if (e.grid_step > e.grid_step_min)
+		    e.grid_step /= 2;
+		else
+		    e.grid_step = e.grid_step_max;
+		RedrawMap = 1;
 	    }
-	 }
-
-      // [e]: Select/unselect all linedefs in non-forked path
-      else if (is.key == 'e' && e.highlighted._is_linedef ())
-	 {
-	 ForgetSelection (&e.Selected);
-	 select_linedefs_path (&e.Selected, e.highlighted.num, YS_ADD);
-	 RedrawMap = 1;
-	 }
 
-      // [Ctrl][e] Select/unselect all linedefs in path
-      else if (is.key == '\5' && ! is.shift && e.highlighted._is_linedef ())
-	 {
-	 select_linedefs_path (&e.Selected, e.highlighted.num, YS_TOGGLE);
-	 RedrawMap = 1;
-	 }
-      // [E]: add linedef and split sector -- [AJA]
-      else if (is.key == 'E' && e.obj_type == OBJ_VERTICES)
-        {
-        if (e.Selected)
-          {
-          MiscOperations (e.obj_type, &e.Selected, 5);
-          RedrawMap = 1;
-          }
-        }
-      // [E]: Select/unselect all 1s linedefs in path
-      else if (is.key == 'E' && e.highlighted._is_linedef ())
-	 {
-	 ForgetSelection (&e.Selected);
-	 select_1s_linedefs_path (&e.Selected, e.highlighted.num, YS_ADD);
-	 RedrawMap = 1;
-	 }
+	    // [h]: display or hide the grid
+	    else if (is.key == 'h')
+	    {
+		e.grid_shown = !e.grid_shown;
+		RedrawMap = 1;
+	    }
+
+	    // [H]: reset the grid to grid_step_max
+	    else if (is.key == 'H')
+	    {
+		e.grid_step = e.grid_step_max;
+		RedrawMap = 1;
+	    }
 
-      // [Ctrl][Shift][e]: Select/unselect all 1s linedefs in path
-      else if (is.key == '\5' && is.shift && e.highlighted._is_linedef ())
-	 {
-	 select_1s_linedefs_path (&e.Selected, e.highlighted.num, YS_TOGGLE);
-	 RedrawMap = 1;
-	 }
+	    // [y]: toggle the snap_to_grid flag
+	    else if (is.key == 'y')
+	    {
+		e.grid_snap = !e.grid_snap;
+	    }
+
+	    // [z]: toggle the lock_grip_step flag
+	    else if (is.key == 'z')
+	    {
+		e.grid_step_locked = !e.grid_step_locked;
+	    }
+
+	    // [r]: toggle the rulers
+	    else if (is.key == 'r')
+		e.rulers_shown = !e.rulers_shown;
 
-      // [G]: to increase the grid step
-      else if (is.key == 'G')
-	 {
-	 if (e.grid_step < e.grid_step_max)
-	    e.grid_step *= 2;
-	 else
-	    e.grid_step = e.grid_step_min;
-	 RedrawMap = 1;
-	 }
-
-      // [g]: decrease the grid step
-      else if (is.key == 'g')
-	 {
-	 if (e.grid_step > e.grid_step_min)
-	    e.grid_step /= 2;
-	 else
-	    e.grid_step = e.grid_step_max;
-	 RedrawMap = 1;
-	 }
-
-      // [h]: display or hide the grid
-      else if (is.key == 'h')
-	 {
-	 e.grid_shown = ! e.grid_shown;
-	 RedrawMap = 1;
-	 }
-
-      // [H]: reset the grid to grid_step_max
-      else if (is.key == 'H')
-	 {
-	 e.grid_step = e.grid_step_max;
-	 RedrawMap = 1;
-	 }
-
-      // [y]: toggle the snap_to_grid flag
-      else if (is.key == 'y')
-         {
-         e.grid_snap = ! e.grid_snap;
-         }
+	    // [n], [>]: highlight the next object
+	    else if ((is.key == 'n' || is.key == '>')
+		     && (!e.global ||e.highlighted()))
+	    {
+		obj_type_t t =
+		    e.highlighted()? e.highlighted.type : e.obj_type;
+		obj_no_t nmax = GetMaxObjectNum(t);
+		if (is_obj(nmax))
+		{
+		    if (e.highlighted.is_nil())
+		    {
+			e.highlighted.type = t;
+			e.highlighted.num = 0;
+		    }
+		    else
+		    {
+			e.highlighted.num++;
+			if (e.highlighted.num > nmax)
+			    e.highlighted.num = 0;
+		    }
+		    GoToObject(e.highlighted);
+		    RedrawMap = 1;
+		}
+	    }
 
-      // [z]: toggle the lock_grip_step flag
-      else if (is.key == 'z')
-         {
-         e.grid_step_locked = ! e.grid_step_locked;
-         }
- 
-      // [r]: toggle the rulers
-      else if (is.key == 'r')
-	 e.rulers_shown = !e.rulers_shown;
-
-      // [n], [>]: highlight the next object
-      else if ((is.key == 'n' || is.key == '>')
-	 && (! e.global || e.highlighted ()))
-	 {
-	 obj_type_t t = e.highlighted () ? e.highlighted.type : e.obj_type;
-	 obj_no_t nmax = GetMaxObjectNum (t);
-	 if (is_obj (nmax))
+	    // [p], [<]: highlight the previous object
+	    else if ((is.key == 'p' || is.key == '<')
+		     && (!e.global ||e.highlighted()))
 	    {
-	    if (e.highlighted.is_nil ())
-	       {
-	       e.highlighted.type = t;
-	       e.highlighted.num = 0;
-	       }
-	    else
-	       {
-	       e.highlighted.num++;
-	       if (e.highlighted.num > nmax)
-		  e.highlighted.num = 0;
-	       }
-	    GoToObject (e.highlighted);
-	    RedrawMap = 1;
+		obj_type_t t =
+		    e.highlighted()? e.highlighted.type : e.obj_type;
+		obj_no_t nmax = GetMaxObjectNum(t);
+		if (is_obj(nmax))
+		{
+		    if (e.highlighted.is_nil())
+		    {
+			e.highlighted.type = t;
+			e.highlighted.num = nmax;
+		    }
+		    else
+		    {
+			e.highlighted.num--;
+			if (e.highlighted.num < 0)
+			    e.highlighted.num = nmax;
+		    }
+		    GoToObject(e.highlighted);
+		    RedrawMap = 1;
+		}
 	    }
-	 }
 
-      // [p], [<]: highlight the previous object
-      else if ((is.key == 'p' || is.key == '<')
-	 && (! e.global || e.highlighted ()))
-	 {
-	 obj_type_t t = e.highlighted () ? e.highlighted.type : e.obj_type;
-	 obj_no_t nmax = GetMaxObjectNum (t);
-	 if (is_obj (nmax))
+	    // [j], [#]: jump to object by number
+	    else if ((is.key == 'j' || is.key == '#')
+		     && (!e.global ||e.highlighted()))
 	    {
-	    if (e.highlighted.is_nil ())
-	       {
-	       e.highlighted.type = t;
-	       e.highlighted.num = nmax;
-	       }
-	    else
-	       {
-	       e.highlighted.num--;
-	       if (e.highlighted.num < 0)
-		  e.highlighted.num = nmax;
-	       }
-	    GoToObject (e.highlighted);
-	    RedrawMap = 1;
+		Objid default_obj;
+		default_obj.type =
+		    e.highlighted()? e.highlighted.type : e.obj_type;
+		default_obj.num = e.highlighted()? e.highlighted.num : 0;
+		Objid target_obj;
+		input_objid(target_obj, default_obj, -1, -1);
+		if (target_obj())
+		    GoToObject(target_obj);
+		RedrawMap = 1;
 	    }
-	 }
-
-      // [j], [#]: jump to object by number
-      else if ((is.key == 'j' || is.key == '#')
-	 && (! e.global || e.highlighted ()))
-	 {
-	 Objid default_obj;
-	 default_obj.type = e.highlighted () ? e.highlighted.type : e.obj_type;
-	 default_obj.num  = e.highlighted () ? e.highlighted.num  : 0;
-	 Objid target_obj;
-	 input_objid (target_obj, default_obj, -1, -1);
-	 if (target_obj ())
-	    GoToObject (target_obj);
-	 RedrawMap = 1;
-	 }
 
-      // [f]: find object by type
-      else if (is.key == 'f' && (! e.global || e.highlighted ())) 
-	 {
-	 Objid find_obj;
-	 int otype;
-	 obj_no_t omax,onum;
-	 find_obj.type = e.highlighted () ? e.highlighted.type : e.obj_type;
-	 onum = find_obj.num  = e.highlighted () ? e.highlighted.num  : 0;
-	 omax = GetMaxObjectNum(find_obj.type);
-         switch (find_obj.type)
-            {
-	    case OBJ_SECTORS:
-               if ( ! InputSectorType( 84, 21, &otype))
-		  {
-	          for (onum = e.highlighted () ? onum + 1 : onum; onum <= omax; onum++)
-	             if (Sectors[onum].special == (wad_stype_t) otype)
-			{
-		        find_obj.num = onum;
-	                GoToObject(find_obj);
-		        break;
-		        }
-		  }
-	    break;
-	    case OBJ_THINGS:
-	       if ( ! InputThingType( 42, 21, &otype))
-	 	  {
-                  for (onum = e.highlighted () ? onum + 1 : onum; onum <= omax; onum++)
-	             if (Things[onum].type == (wad_ttype_t) otype)
-                        {
-		        find_obj.num = onum;
-	                GoToObject(find_obj);
-		        break;
-		        }
-		  }
-	    break;
-	    case OBJ_LINEDEFS:
-	       if ( ! InputLinedefType( 0, 21, &otype))
-		  {
-	          for (onum = e.highlighted () ? onum + 1 : onum; onum <= omax; onum++)
-		     if (LineDefs[onum].type == (wad_ldtype_t) otype)
-			{
-		        find_obj.num = onum;
-	                GoToObject(find_obj);
-			break;
-		        }
-		  }
-	    break;
+	    // [f]: find object by type
+	    else if (is.key == 'f' && (!e.global ||e.highlighted()))
+	    {
+		Objid find_obj;
+		int otype;
+		obj_no_t omax, onum;
+		find_obj.type =
+		    e.highlighted()? e.highlighted.type : e.obj_type;
+		onum = find_obj.num = e.highlighted()? e.highlighted.num : 0;
+		omax = GetMaxObjectNum(find_obj.type);
+		switch (find_obj.type)
+		{
+		case OBJ_SECTORS:
+		    if (!InputSectorType(84, 21, &otype))
+		    {
+			for (onum = e.highlighted()? onum + 1 : onum;
+			     onum <= omax; onum++)
+			    if (Sectors[onum].special == (wad_stype_t) otype)
+			    {
+				find_obj.num = onum;
+				GoToObject(find_obj);
+				break;
+			    }
+		    }
+		    break;
+		case OBJ_THINGS:
+		    if (!InputThingType(42, 21, &otype))
+		    {
+			for (onum = e.highlighted()? onum + 1 : onum;
+			     onum <= omax; onum++)
+			    if (Things[onum].type == (wad_ttype_t) otype)
+			    {
+				find_obj.num = onum;
+				GoToObject(find_obj);
+				break;
+			    }
+		    }
+		    break;
+		case OBJ_LINEDEFS:
+		    if (!InputLinedefType(0, 21, &otype))
+		    {
+			for (onum = e.highlighted()? onum + 1 : onum;
+			     onum <= omax; onum++)
+			    if (LineDefs[onum].type == (wad_ldtype_t) otype)
+			    {
+				find_obj.num = onum;
+				GoToObject(find_obj);
+				break;
+			    }
+		    }
+		    break;
+		}
+		RedrawMap = 1;
 	    }
-         RedrawMap = 1;
-         }
 #if 0
-      // [c]: clear selection and redraw the map
-      else if (is.key == 'c')
-	 {
-	 ForgetSelection (&e.Selected);
-	 RedrawMap = 1;
-	 DragObject = false;
-	 StretchSelBox = false;
-	 }
+	    // [c]: clear selection and redraw the map
+	    else if (is.key == 'c')
+	    {
+		ForgetSelection(&e.Selected);
+		RedrawMap = 1;
+		DragObject = false;
+		StretchSelBox = false;
+	    }
 #endif
 
-      // [o]: copy a group of objects
-      else if (is.key == 'o'
-         && (e.Selected || e.highlighted ()))
-	 {
-         int x, y;
-
-	 /* copy the object(s) */
-	 if (! e.Selected)
-	    SelectObject (&e.Selected, e.highlighted.num);
-	 CopyObjects (e.obj_type, e.Selected);
-	 /* enter drag mode */
-	 //DragObject = true;
-         /* AYM 19980619 : got to look into this!! */
-	 //e.highlight_obj_no = e.Selected->objnum;
-
-         // Find the "hotspot" in the object(s)
-         if (e.highlighted () && ! e.Selected)
-            GetObjectCoords (e.highlighted.type, e.highlighted.num, &x, &y);
-         else
-            centre_of_objects (e.obj_type, e.Selected, &x, &y);
-
-         // Drag the object(s) so that the "hotspot" is under the pointer
-         MoveObjectsToCoords (e.obj_type, 0, x, y, 0);
-         MoveObjectsToCoords (e.obj_type, e.Selected,
-            e.pointer_x, e.pointer_y, 0);
-	 RedrawMap = 1;
-	 StretchSelBox = false;
-	 }
-
-      // [Return]: edit the properties of the current object.
-      else if (is.key == YK_RETURN
-         && (e.Selected || e.highlighted ()))
-	 {
-	 if (e.Selected)
-	    EditObjectsInfo (0, menubar_out_y1 + 1, e.obj_type, e.Selected);
-	 else
+	    // [o]: copy a group of objects
+	    else if (is.key == 'o' && (e.Selected || e.highlighted()))
 	    {
-	    SelectObject (&e.Selected, e.highlighted.num);
-	    EditObjectsInfo (0, menubar_out_y1 + 1, e.highlighted.type, e.Selected);
-	    UnSelectObject (&e.Selected, e.highlighted.num);
-	    }
-	 RedrawMap = 1;
-	 DragObject = false;
-	 StretchSelBox = false;
-	 }
+		int x, y;
+
+		/* copy the object(s) */
+		if (!e.Selected)
+		    SelectObject(&e.Selected, e.highlighted.num);
+		CopyObjects(e.obj_type, e.Selected);
+		/* enter drag mode */
+		//DragObject = true;
+		/* AYM 19980619 : got to look into this!! */
+		//e.highlight_obj_no = e.Selected->objnum;
 
-      // [w]: spin things 1/8 turn counter-clockwise
-      else if (is.key == 'w' && e.obj_type == OBJ_THINGS
-         && (e.Selected || e.highlighted ()))
-	 {
-	 if (! e.Selected)
-	    {
-	    SelectObject (&e.Selected, e.highlighted.num);
-	    spin_things (e.Selected, 45);
-	    UnSelectObject (&e.Selected, e.highlighted.num);
+		// Find the "hotspot" in the object(s)
+		if (e.highlighted() && !e.Selected)
+		    GetObjectCoords(e.highlighted.type, e.highlighted.num, &x,
+				    &y);
+		else
+		    centre_of_objects(e.obj_type, e.Selected, &x, &y);
+
+		// Drag the object(s) so that the "hotspot" is under the pointer
+		MoveObjectsToCoords(e.obj_type, 0, x, y, 0);
+		MoveObjectsToCoords(e.obj_type, e.Selected,
+				    e.pointer_x, e.pointer_y, 0);
+		RedrawMap = 1;
+		StretchSelBox = false;
 	    }
-	 else
-	    {
-	    spin_things (e.Selected, 45);
-	    }
-	 RedrawMap = 1;  /* FIXME: should redraw only the things */
-	 DragObject = false;
-	 StretchSelBox = false;
-	 }
-
-      // [w]: split linedefs and sectors
-      else if (is.key == 'w' && e.obj_type == OBJ_LINEDEFS
-         && e.Selected && e.Selected->next && ! e.Selected->next->next)
-         {
-         SplitLineDefsAndSector (e.Selected->next->objnum, e.Selected->objnum);
-         ForgetSelection (&e.Selected);
-         RedrawMap = 1;
-         DragObject = false;
-         StretchSelBox = false;
-         }
 
-      // [w]: split sector between vertices
-      else if (is.key == 'w' && e.obj_type == OBJ_VERTICES
-         && e.Selected && e.Selected->next && ! e.Selected->next->next)
-         {
-         SplitSector (e.Selected->next->objnum, e.Selected->objnum);
-         ForgetSelection (&e.Selected);
-         RedrawMap = 1;
-         DragObject = false;
-         StretchSelBox = false;
-         }
-
-      // [x]: spin things 1/8 turn clockwise
-      else if (is.key == 'x' && e.obj_type == OBJ_THINGS
-         && (e.Selected || e.highlighted ()))
-	 {
-	 if (! e.Selected)
+	    // [Return]: edit the properties of the current object.
+	    else if (is.key == YK_RETURN && (e.Selected || e.highlighted()))
 	    {
-	    SelectObject (&e.Selected, e.highlighted.num);
-	    spin_things (e.Selected, -45);
-	    UnSelectObject (&e.Selected, e.highlighted.num);
+		if (e.Selected)
+		    EditObjectsInfo(0, menubar_out_y1 + 1, e.obj_type,
+				    e.Selected);
+		else
+		{
+		    SelectObject(&e.Selected, e.highlighted.num);
+		    EditObjectsInfo(0, menubar_out_y1 + 1, e.highlighted.type,
+				    e.Selected);
+		    UnSelectObject(&e.Selected, e.highlighted.num);
+		}
+		RedrawMap = 1;
+		DragObject = false;
+		StretchSelBox = false;
 	    }
-	 else
-	    {
-	    spin_things (e.Selected, -45);
-	    }
-	 RedrawMap = 1;  /* FIXME: should redraw only the things */
-	 DragObject = false;
-	 StretchSelBox = false;
-	 }
 
-      // [x]: split linedefs
-      else if (is.key == 'x' && e.obj_type == OBJ_LINEDEFS
-         && (e.Selected || e.highlighted ()))
-         {
-         if (! e.Selected)
-            {
-            SelectObject (&e.Selected, e.highlighted.num);
-            SplitLineDefs (e.Selected);
-            UnSelectObject (&e.Selected, e.highlighted.num);
-            }
-         else
-            SplitLineDefs (e.Selected);
-         RedrawMap = 1;
-         DragObject = false;
-         StretchSelBox = false;
-         }
-
-      // [Ctrl][x]: exchange objects numbers
-      else if (is.key == 24)
-	 {
-	 if (! e.Selected
-	     || ! e.Selected->next
-	     || (e.Selected->next)->next)
-	    {
-	    Beep ();
-	    Notify (-1, -1, "You must select exactly two objects", 0);
-	    RedrawMap = 1;
-	    }
-	 else
+	    // [w]: spin things 1/8 turn counter-clockwise
+	    else if (is.key == 'w' && e.obj_type == OBJ_THINGS
+		     && (e.Selected || e.highlighted()))
 	    {
-	    exchange_objects_numbers (e.obj_type, e.Selected, true);
-	    RedrawMap = 1;
+		if (!e.Selected)
+		{
+		    SelectObject(&e.Selected, e.highlighted.num);
+		    spin_things(e.Selected, 45);
+		    UnSelectObject(&e.Selected, e.highlighted.num);
+		}
+		else
+		{
+		    spin_things(e.Selected, 45);
+		}
+		RedrawMap = 1;	/* FIXME: should redraw only the things */
+		DragObject = false;
+		StretchSelBox = false;
 	    }
-	 }
 
-      // [Ctrl][k]: cut a slice out of a sector
-      else if (is.key == 11 && e.obj_type == OBJ_LINEDEFS
-         && e.Selected && e.Selected->next && ! e.Selected->next->next)
-      {
-         sector_slice (e.Selected->next->objnum, e.Selected->objnum);
-         ForgetSelection (&e.Selected);
-         RedrawMap = 1;
-         DragObject = false;
-         StretchSelBox = false;
-      }
-      
-      // [Del]: delete the current object
-      else if (is.key == YK_DEL
-         && (e.Selected || e.highlighted ())) /* 'Del' */
-	 {
-	 if (e.obj_type == OBJ_THINGS
-	  || Expert
-	  || Confirm (-1, -1,
-		(e.Selected && e.Selected->next ?
-		     "Do you really want to delete these objects?"
-		   : "Do you really want to delete this object?"),
-		(e.Selected && e.Selected->next ?
-		     "This will also delete the objects bound to them."
-	           : "This will also delete the objects bound to it.")))
+	    // [w]: split linedefs and sectors
+	    else if (is.key == 'w' && e.obj_type == OBJ_LINEDEFS
+		     && e.Selected && e.Selected->next
+		     && !e.Selected->next->next)
+	    {
+		SplitLineDefsAndSector(e.Selected->next->objnum,
+				       e.Selected->objnum);
+		ForgetSelection(&e.Selected);
+		RedrawMap = 1;
+		DragObject = false;
+		StretchSelBox = false;
+	    }
+
+	    // [w]: split sector between vertices
+	    else if (is.key == 'w' && e.obj_type == OBJ_VERTICES
+		     && e.Selected && e.Selected->next
+		     && !e.Selected->next->next)
 	    {
-	    if (e.Selected)
-	       DeleteObjects (e.obj_type, &e.Selected);
-	    else
-	       DeleteObject (e.highlighted);
+		SplitSector(e.Selected->next->objnum, e.Selected->objnum);
+		ForgetSelection(&e.Selected);
+		RedrawMap = 1;
+		DragObject = false;
+		StretchSelBox = false;
 	    }
-         // AYM 1998-09-20 I thought I'd add this
-         // (though it doesn't fix the problem : if the object has been
-         // deleted, HighlightObject is still called with a bad object#).
-         e.highlighted.nil ();
-	 DragObject = false;
-	 StretchSelBox = false;
-	 RedrawMap = 1;
-	 }
-
-      // [Ins]: insert a new object
-      else if (is.key == YK_INS || is.key == YK_INS + YK_SHIFT) /* 'Ins' */
-	 {
-	 SelPtr cur;
-         int prev_obj_type = e.obj_type;
-
-	 /* first special case: if several vertices are
-	    selected, add new linedefs */
-	 if (e.obj_type == OBJ_VERTICES
-	    && e.Selected && e.Selected->next)
-	    {
-	    int firstv;
-            int obj_no = OBJ_NO_NONE;
 
-	    if (e.Selected->next->next)
-	       firstv = e.Selected->objnum;
-	    else
-	       firstv = -1;
-	    e.obj_type = OBJ_LINEDEFS;
-	    /* create linedefs between the vertices */
-	    for (cur = e.Selected; cur->next; cur = cur->next)
-	       {
-	       /* check if there is already a linedef between the two vertices */
-	       for (obj_no = 0; obj_no < NumLineDefs; obj_no++)
-		  if ((LineDefs[obj_no].start == cur->next->objnum
-		    && LineDefs[obj_no].end   == cur->objnum)
-		   || (LineDefs[obj_no].end   == cur->next->objnum
-		    && LineDefs[obj_no].start == cur->objnum))
-		     break;
-	       if (obj_no < NumLineDefs)
-		  cur->objnum = obj_no;
-	       else
-		  {
-		  InsertObject (OBJ_LINEDEFS, -1, 0, 0);
-		  e.highlighted.type = OBJ_LINEDEFS;
-		  e.highlighted.num  = NumLineDefs - 1;
-		  LineDefs[e.highlighted.num].start = cur->next->objnum;
-		  LineDefs[e.highlighted.num].end = cur->objnum;
-		  cur->objnum = e.highlighted.num;  // FIXME cur = e.highlighted
-		  }
-	       }
-	    /* close the polygon if there are more than 2 vertices */
-	    if (firstv >= 0 && is.shift)
-	       {
-	       e.highlighted.type = OBJ_LINEDEFS;
-	       for (e.highlighted.num = 0;
-                    e.highlighted.num < NumLineDefs;
-                    e.highlighted.num++)
-		  if ((LineDefs[e.highlighted.num].start == firstv
-		    && LineDefs[e.highlighted.num].end   == cur->objnum)
-		   || (LineDefs[e.highlighted.num].end   == firstv
-		    && LineDefs[e.highlighted.num].start == cur->objnum))
-		     break;
-	       if (e.highlighted.num < NumLineDefs)
-		  cur->objnum = obj_no;
-	       else
-		  {
-		  InsertObject (OBJ_LINEDEFS, -1, 0, 0);
-		  e.highlighted.type = OBJ_LINEDEFS;
-		  e.highlighted.num  = NumLineDefs - 1;
-		  LineDefs[e.highlighted.num].start = firstv;
-		  LineDefs[e.highlighted.num].end   = cur->objnum;
-		  cur->objnum = e.highlighted.num;  // FIXME cur = e.highlighted
-		  }
-	       }
-	    else
-	       UnSelectObject (&e.Selected, cur->objnum);
+	    // [x]: spin things 1/8 turn clockwise
+	    else if (is.key == 'x' && e.obj_type == OBJ_THINGS
+		     && (e.Selected || e.highlighted()))
+	    {
+		if (!e.Selected)
+		{
+		    SelectObject(&e.Selected, e.highlighted.num);
+		    spin_things(e.Selected, -45);
+		    UnSelectObject(&e.Selected, e.highlighted.num);
+		}
+		else
+		{
+		    spin_things(e.Selected, -45);
+		}
+		RedrawMap = 1;	/* FIXME: should redraw only the things */
+		DragObject = false;
+		StretchSelBox = false;
 	    }
-	 /* second special case: if several linedefs are selected,
-	    add new sidedefs and one sector */
-	 else if (e.obj_type == OBJ_LINEDEFS && e.Selected)
+
+	    // [x]: split linedefs
+	    else if (is.key == 'x' && e.obj_type == OBJ_LINEDEFS
+		     && (e.Selected || e.highlighted()))
+	    {
+		if (!e.Selected)
+		{
+		    SelectObject(&e.Selected, e.highlighted.num);
+		    SplitLineDefs(e.Selected);
+		    UnSelectObject(&e.Selected, e.highlighted.num);
+		}
+		else
+		    SplitLineDefs(e.Selected);
+		RedrawMap = 1;
+		DragObject = false;
+		StretchSelBox = false;
+	    }
+
+	    // [Ctrl][x]: exchange objects numbers
+	    else if (is.key == 24)
 	    {
-	    for (cur = e.Selected; cur; cur = cur->next)
-	       if (LineDefs[cur->objnum].sidedef1 >= 0
-		&& LineDefs[cur->objnum].sidedef2 >= 0)
-		  {
-		  char msg[80];
+		if (!e.Selected
+		    || !e.Selected->next || (e.Selected->next)->next)
+		{
+		    Beep();
+		    Notify(-1, -1, "You must select exactly two objects", 0);
+		    RedrawMap = 1;
+		}
+		else
+		{
+		    exchange_objects_numbers(e.obj_type, e.Selected, true);
+		    RedrawMap = 1;
+		}
+	    }
 
-		  Beep ();
-		  sprintf (msg, "Linedef #%d already has two sidedefs", cur->objnum);
-		  Notify (-1, -1, "Error: cannot add the new sector", msg);
-		  break;
-		  }
-	    if (! cur)
-	       {
-	       e.obj_type = OBJ_SECTORS;
-	       InsertObject (OBJ_SECTORS, -1, 0, 0);
-	       e.highlighted.type = OBJ_SECTORS;
-	       e.highlighted.num  = NumSectors - 1;
-	       for (cur = e.Selected; cur; cur = cur->next)
-		  {
-		  InsertObject (OBJ_SIDEDEFS, -1, 0, 0);
-		  SideDefs[NumSideDefs - 1].sector = e.highlighted.num;
-		  if (LineDefs[cur->objnum].sidedef1 >= 0)
-		     {
-		     int s;
+	    // [Ctrl][k]: cut a slice out of a sector
+	    else if (is.key == 11 && e.obj_type == OBJ_LINEDEFS
+		     && e.Selected && e.Selected->next
+		     && !e.Selected->next->next)
+	    {
+		sector_slice(e.Selected->next->objnum, e.Selected->objnum);
+		ForgetSelection(&e.Selected);
+		RedrawMap = 1;
+		DragObject = false;
+		StretchSelBox = false;
+	    }
 
-		     s = SideDefs[LineDefs[cur->objnum].sidedef1].sector;
-		     if (s >= 0)
-			{
-			Sectors[e.highlighted.num].floorh = Sectors[s].floorh;
-			Sectors[e.highlighted.num].ceilh = Sectors[s].ceilh;
-			strncpy (Sectors[e.highlighted.num].floort,
-			   Sectors[s].floort, WAD_FLAT_NAME);
-			strncpy (Sectors[e.highlighted.num].ceilt,
-			   Sectors[s].ceilt, WAD_FLAT_NAME);
-			Sectors[e.highlighted.num].light = Sectors[s].light;
-			}
-		     LineDefs[cur->objnum].sidedef2 = NumSideDefs - 1;
-		     LineDefs[cur->objnum].flags = 4;
-		     strncpy (SideDefs[NumSideDefs - 1].tex3,
-			 "-", WAD_TEX_NAME);
-		     strncpy (SideDefs[LineDefs[cur->objnum].sidedef1].tex3,
-			 "-", WAD_TEX_NAME);
-		     }
-		  else
-		     LineDefs[cur->objnum].sidedef1 = NumSideDefs - 1;
-		  }
-	       ForgetSelection (&e.Selected);
-	       SelectObject (&e.Selected, e.highlighted.num);
-	       }
-	    }
-	 /* normal case: add a new object of the current type */
-	 else
+	    // [Del]: delete the current object
+	    else if (is.key == YK_DEL && (e.Selected || e.highlighted()))	/* 'Del' */
 	    {
-	    ForgetSelection (&e.Selected);
-	    /* FIXME how do you insert a new object of type T if
-	       no object of that type already exists ? */
-	    obj_type_t t = e.highlighted () ? e.highlighted.type : e.obj_type;
-	    InsertObject (t, e.highlighted.num,
-	       edit_mapx_snapped (&e, e.pointer_x),
-	       edit_mapy_snapped (&e, e.pointer_y));
-	    e.highlighted.type = t;
-	    e.highlighted.num  = GetMaxObjectNum (e.obj_type);
-	    if (e.obj_type == OBJ_LINEDEFS)
-	       {
-	       int v1 = LineDefs[e.highlighted.num].start;
-	       int v2 = LineDefs[e.highlighted.num].end;
-	       if (! Input2VertexNumbers (-1, -1,
-		 "Choose the two vertices for the new linedef", &v1, &v2))
-		  {
-		  DeleteObject (e.highlighted);
-		  e.highlighted.nil ();
-		  }
-	       else
-		  {
-		  LineDefs[e.highlighted.num].start = v1;
-		  LineDefs[e.highlighted.num].end   = v2;
-		  }
-	       }
-	    else if (e.obj_type == OBJ_VERTICES)
-	       {
-	       SelectObject (&e.Selected, e.highlighted.num);
-	       if (AutoMergeVertices (&e.Selected, e.obj_type, 'i'))
-		  RedrawMap = 1;
-	       ForgetSelection (&e.Selected);
-	       }
+		if (e.obj_type == OBJ_THINGS
+		    || Expert
+		    || Confirm(-1, -1,
+			       (e.Selected && e.Selected->next ?
+				"Do you really want to delete these objects?"
+				:
+				"Do you really want to delete this object?"),
+			       (e.Selected
+				&& e.Selected->
+				next ?
+				"This will also delete the objects bound to them."
+				:
+				"This will also delete the objects bound to it.")))
+		{
+		    if (e.Selected)
+			DeleteObjects(e.obj_type, &e.Selected);
+		    else
+			DeleteObject(e.highlighted);
+		}
+		// AYM 1998-09-20 I thought I'd add this
+		// (though it doesn't fix the problem : if the object has been
+		// deleted, HighlightObject is still called with a bad object#).
+		e.highlighted.nil();
+		DragObject = false;
+		StretchSelBox = false;
+		RedrawMap = 1;
 	    }
 
-         // Mode-changing code, duplicated from above.
-         // As RQ would say: "I hate to do that". So do I.
-         // The best solution would be to have a mode
-         // changing function that only changes e.obj_type
-         // and emits a "mode change" message. Another part
-         // of the code, responsible for the menus, would
-         // intercept that message and update them. I don't
-         // have the time (as of 1998-12-14) to do it now.
-         if (e.obj_type != prev_obj_type)
+	    // [Ins]: insert a new object
+	    else if (is.key == YK_INS || is.key == YK_INS + YK_SHIFT)	/* 'Ins' */
 	    {
-	    int new_mode;
+		SelPtr cur;
+		int prev_obj_type = e.obj_type;
+
+		/* first special case: if several vertices are
+		   selected, add new linedefs */
+		if (e.obj_type == OBJ_VERTICES
+		    && e.Selected && e.Selected->next)
+		{
+		    int firstv;
+		    int obj_no = OBJ_NO_NONE;
+
+		    if (e.Selected->next->next)
+			firstv = e.Selected->objnum;
+		    else
+			firstv = -1;
+		    e.obj_type = OBJ_LINEDEFS;
+		    /* create linedefs between the vertices */
+		    for (cur = e.Selected; cur->next; cur = cur->next)
+		    {
+			/* check if there is already a linedef between the two vertices */
+			for (obj_no = 0; obj_no < NumLineDefs; obj_no++)
+			    if ((LineDefs[obj_no].start == cur->next->objnum
+				 && LineDefs[obj_no].end == cur->objnum)
+				|| (LineDefs[obj_no].end == cur->next->objnum
+				    && LineDefs[obj_no].start == cur->objnum))
+				break;
+			if (obj_no < NumLineDefs)
+			    cur->objnum = obj_no;
+			else
+			{
+			    InsertObject(OBJ_LINEDEFS, -1, 0, 0);
+			    e.highlighted.type = OBJ_LINEDEFS;
+			    e.highlighted.num = NumLineDefs - 1;
+			    LineDefs[e.highlighted.num].start =
+				cur->next->objnum;
+			    LineDefs[e.highlighted.num].end = cur->objnum;
+			    cur->objnum = e.highlighted.num;	// FIXME cur = e.highlighted
+			}
+		    }
+		    /* close the polygon if there are more than 2 vertices */
+		    if (firstv >= 0 && is.shift)
+		    {
+			e.highlighted.type = OBJ_LINEDEFS;
+			for (e.highlighted.num = 0;
+			     e.highlighted.num < NumLineDefs;
+			     e.highlighted.num++)
+			    if ((LineDefs[e.highlighted.num].start == firstv
+				 && LineDefs[e.highlighted.num].end ==
+				 cur->objnum)
+				|| (LineDefs[e.highlighted.num].end == firstv
+				    && LineDefs[e.highlighted.num].start ==
+				    cur->objnum))
+				break;
+			if (e.highlighted.num < NumLineDefs)
+			    cur->objnum = obj_no;
+			else
+			{
+			    InsertObject(OBJ_LINEDEFS, -1, 0, 0);
+			    e.highlighted.type = OBJ_LINEDEFS;
+			    e.highlighted.num = NumLineDefs - 1;
+			    LineDefs[e.highlighted.num].start = firstv;
+			    LineDefs[e.highlighted.num].end = cur->objnum;
+			    cur->objnum = e.highlighted.num;	// FIXME cur = e.highlighted
+			}
+		    }
+		    else
+			UnSelectObject(&e.Selected, cur->objnum);
+		}
+		/* second special case: if several linedefs are selected,
+		   add new sidedefs and one sector */
+		else if (e.obj_type == OBJ_LINEDEFS && e.Selected)
+		{
+		    for (cur = e.Selected; cur; cur = cur->next)
+			if (LineDefs[cur->objnum].sidedef1 >= 0
+			    && LineDefs[cur->objnum].sidedef2 >= 0)
+			{
+			    char msg[80];
 
-	    // What's the number of the new mode ?
-            new_mode = obj_type_to_mode_no (e.obj_type);
+			    Beep();
+			    sprintf(msg,
+				    "Linedef #%d already has two sidedefs",
+				    cur->objnum);
+			    Notify(-1, -1, "Error: cannot add the new sector",
+				   msg);
+			    break;
+			}
+		    if (!cur)
+		    {
+			e.obj_type = OBJ_SECTORS;
+			InsertObject(OBJ_SECTORS, -1, 0, 0);
+			e.highlighted.type = OBJ_SECTORS;
+			e.highlighted.num = NumSectors - 1;
+			for (cur = e.Selected; cur; cur = cur->next)
+			{
+			    InsertObject(OBJ_SIDEDEFS, -1, 0, 0);
+			    SideDefs[NumSideDefs - 1].sector =
+				e.highlighted.num;
+			    if (LineDefs[cur->objnum].sidedef1 >= 0)
+			    {
+				int s;
 
-	    // Change the flavour of the "Misc" menu.
-	    e.menubar->set_menu (e.mb_ino[MBI_MISC],
-	       e.mb_menu[modes[new_mode].menu_no]);
+				s = SideDefs[LineDefs[cur->objnum].sidedef1].
+				    sector;
+				if (s >= 0)
+				{
+				    Sectors[e.highlighted.num].floorh =
+					Sectors[s].floorh;
+				    Sectors[e.highlighted.num].ceilh =
+					Sectors[s].ceilh;
+				    strncpy(Sectors[e.highlighted.num].floort,
+					    Sectors[s].floort, WAD_FLAT_NAME);
+				    strncpy(Sectors[e.highlighted.num].ceilt,
+					    Sectors[s].ceilt, WAD_FLAT_NAME);
+				    Sectors[e.highlighted.num].light =
+					Sectors[s].light;
+				}
+				LineDefs[cur->objnum].sidedef2 =
+				    NumSideDefs - 1;
+				LineDefs[cur->objnum].flags = 4;
+				strncpy(SideDefs[NumSideDefs - 1].tex3,
+					"-", WAD_TEX_NAME);
+				strncpy(SideDefs
+					[LineDefs[cur->objnum].sidedef1].tex3,
+					"-", WAD_TEX_NAME);
+			    }
+			    else
+				LineDefs[cur->objnum].sidedef1 =
+				    NumSideDefs - 1;
+			}
+			ForgetSelection(&e.Selected);
+			SelectObject(&e.Selected, e.highlighted.num);
+		    }
+		}
+		/* normal case: add a new object of the current type */
+		else
+		{
+		    ForgetSelection(&e.Selected);
+		    /* FIXME how do you insert a new object of type T if
+		       no object of that type already exists ? */
+		    obj_type_t t =
+			e.highlighted()? e.highlighted.type : e.obj_type;
+		    InsertObject(t, e.highlighted.num,
+				 edit_mapx_snapped(&e, e.pointer_x),
+				 edit_mapy_snapped(&e, e.pointer_y));
+		    e.highlighted.type = t;
+		    e.highlighted.num = GetMaxObjectNum(e.obj_type);
+		    if (e.obj_type == OBJ_LINEDEFS)
+		    {
+			int v1 = LineDefs[e.highlighted.num].start;
+			int v2 = LineDefs[e.highlighted.num].end;
+			if (!Input2VertexNumbers(-1, -1,
+						 "Choose the two vertices for the new linedef",
+						 &v1, &v2))
+			{
+			    DeleteObject(e.highlighted);
+			    e.highlighted.nil();
+			}
+			else
+			{
+			    LineDefs[e.highlighted.num].start = v1;
+			    LineDefs[e.highlighted.num].end = v2;
+			}
+		    }
+		    else if (e.obj_type == OBJ_VERTICES)
+		    {
+			SelectObject(&e.Selected, e.highlighted.num);
+			if (AutoMergeVertices(&e.Selected, e.obj_type, 'i'))
+			    RedrawMap = 1;
+			ForgetSelection(&e.Selected);
+		    }
+		}
+
+		// Mode-changing code, duplicated from above.
+		// As RQ would say: "I hate to do that". So do I.
+		// The best solution would be to have a mode
+		// changing function that only changes e.obj_type
+		// and emits a "mode change" message. Another part
+		// of the code, responsible for the menus, would
+		// intercept that message and update them. I don't
+		// have the time (as of 1998-12-14) to do it now.
+		if (e.obj_type != prev_obj_type)
+		{
+		    int new_mode;
+
+		    // What's the number of the new mode ?
+		    new_mode = obj_type_to_mode_no(e.obj_type);
+
+		    // Change the flavour of the "Misc" menu.
+		    e.menubar->set_menu(e.mb_ino[MBI_MISC],
+					e.mb_menu[modes[new_mode].menu_no]);
+		}
+
+		DragObject = false;
+		StretchSelBox = false;
+		RedrawMap = 1;
 	    }
 
-	 DragObject = false;
-	 StretchSelBox = false;
-	 RedrawMap = 1;
-	 }
+	    // [Z] Set sector on surrounding linedefs (AJA)
+	    else if (is.key == 'Z' && e.pointer_in_window)
+	    {
+		if (e.obj_type == OBJ_SECTORS && e.Selected)
+		{
+		    SuperSectorSelector(e.pointer_x, e.pointer_y,
+					e.Selected->objnum);
+		}
+		else
+		{
+		    SuperSectorSelector(e.pointer_x, e.pointer_y,
+					OBJ_NO_NONE);
+		}
+		RedrawMap = 1;
+	    }
 
-      // [Z] Set sector on surrounding linedefs (AJA)
-      else if (is.key == 'Z' && e.pointer_in_window) 
-         {
-         if (e.obj_type == OBJ_SECTORS && e.Selected)
-            {
-            SuperSectorSelector (e.pointer_x, e.pointer_y,
-               e.Selected->objnum);
-            }
-         else
-            {
-            SuperSectorSelector (e.pointer_x, e.pointer_y, OBJ_NO_NONE);
-            }
-         RedrawMap = 1;
-         }
+	    // [!] Debug info (not documented)
+	    else if (is.key == '!')
+	    {
+		DumpSelection(e.Selected);
+	    }
 
-      // [!] Debug info (not documented)
-      else if (is.key == '!')
-         {
-         DumpSelection (e.Selected);
-         }
-
-      // [R] Render 3D view (AJA)
-      else if (is.key == 'R')
-        {
-        Render3D ();
-        RedrawMap = 1;
-        }
+	    // [R] Render 3D view (AJA)
+	    else if (is.key == 'R')
+	    {
+		Render3D();
+		RedrawMap = 1;
+	    }
 
-      // [T] Transfer properties to selected objects (AJA)
-      else if (is.key == 'T' && e.Selected 
-            && e.highlighted.num >= 0)
-         {
-         switch (e.obj_type)
-            {
-            case OBJ_SECTORS:
-               TransferSectorProperties (e.highlighted.num, e.Selected);
-               RedrawMap = 1;
-               break;
-            case OBJ_THINGS:
-               TransferThingProperties (e.highlighted.num, e.Selected);
-               RedrawMap = 1;
-               break;
-            case OBJ_LINEDEFS:
-               TransferLinedefProperties (e.highlighted.num, e.Selected);
-               RedrawMap = 1;
-               break;
-            default:
-               Beep ();
-               break;
-            }
-         }
+	    // [T] Transfer properties to selected objects (AJA)
+	    else if (is.key == 'T' && e.Selected && e.highlighted.num >= 0)
+	    {
+		switch (e.obj_type)
+		{
+		case OBJ_SECTORS:
+		    TransferSectorProperties(e.highlighted.num, e.Selected);
+		    RedrawMap = 1;
+		    break;
+		case OBJ_THINGS:
+		    TransferThingProperties(e.highlighted.num, e.Selected);
+		    RedrawMap = 1;
+		    break;
+		case OBJ_LINEDEFS:
+		    TransferLinedefProperties(e.highlighted.num, e.Selected);
+		    RedrawMap = 1;
+		    break;
+		default:
+		    Beep();
+		    break;
+		}
+	    }
 
-      // [Ctrl][b] Select linedefs whose sidedefs reference non-existant sectors
-      else if (is.key == 2)
-	 {
-	 bad_sector_number (&e.Selected);
-	 RedrawMap = 1;
-         }
+	    // [Ctrl][b] Select linedefs whose sidedefs reference non-existant sectors
+	    else if (is.key == 2)
+	    {
+		bad_sector_number(&e.Selected);
+		RedrawMap = 1;
+	    }
 
-      // [Ctrl][p] Examine game palette (not documented)
-      else if (is.key == 16)
-         {
-	 Palette_viewer pv;
-	 pv.run ();
-	 RedrawMap = 1;
-         }
+	    // [Ctrl][p] Examine game palette (not documented)
+	    else if (is.key == 16)
+	    {
+		Palette_viewer pv;
+		pv.run();
+		RedrawMap = 1;
+	    }
 
-      // [Ctrl][r] Xref for sidedef (not documented)
-      else if (is.key == 18)
-	 {
-	 xref_sidedef ();
-	 }
+	    // [Ctrl][r] Xref for sidedef (not documented)
+	    else if (is.key == 18)
+	    {
+		xref_sidedef();
+	    }
 
-      // [Ctrl][s] List secret sectors (not documented)
-      else if (is.key == 19)
-	 {
-	 secret_sectors ();
-	 }
+	    // [Ctrl][s] List secret sectors (not documented)
+	    else if (is.key == 19)
+	    {
+		secret_sectors();
+	    }
 
-      // [Ctrl][t] List tagged linedefs or sectors
-      else if (is.key == 20)
-	 {
-	 if (e.highlighted._is_sector ())
-	    list_tagged_linedefs (Sectors[e.highlighted.num].tag);
-	 else if (e.highlighted._is_linedef ())
-	    list_tagged_sectors (LineDefs[e.highlighted.num].tag);
-	 else
-	    Beep ();
-	 }
+	    // [Ctrl][t] List tagged linedefs or sectors
+	    else if (is.key == 20)
+	    {
+		if (e.highlighted._is_sector())
+		    list_tagged_linedefs(Sectors[e.highlighted.num].tag);
+		else if (e.highlighted._is_linedef())
+		    list_tagged_sectors(LineDefs[e.highlighted.num].tag);
+		else
+		    Beep();
+	    }
 
-      // [Ctrl][u] Select linedefs with unknown type (not documented)
-      else if (is.key == 21)
-	 {
-	 unknown_linedef_type (&e.Selected);
-	 RedrawMap = 1;
-	 }
+	    // [Ctrl][u] Select linedefs with unknown type (not documented)
+	    else if (is.key == 21)
+	    {
+		unknown_linedef_type(&e.Selected);
+		RedrawMap = 1;
+	    }
 
-      // [Ctrl][v] Toggle between "snap vertex" tool and normal tool
-      // (not documented)
-      else if (is.key == 22)
-	 {
-	 if (e.tool == TOOL_NORMAL)
+	    // [Ctrl][v] Toggle between "snap vertex" tool and normal tool
+	    // (not documented)
+	    else if (is.key == 22)
 	    {
-	    e.tool = TOOL_SNAP_VERTEX;
-	    printf ("Switched to snap vertex tool."
-		  " Press [Ctrl][v] to switch back to normal tool.\n");
+		if (e.tool == TOOL_NORMAL)
+		{
+		    e.tool = TOOL_SNAP_VERTEX;
+		    printf("Switched to snap vertex tool."
+			   " Press [Ctrl][v] to switch back to normal tool.\n");
+		}
+		else
+		{
+		    e.tool = TOOL_NORMAL;
+		    printf("Switched back to normal tool.\n");
+		}
 	    }
-	 else
-	    {
-	    e.tool = TOOL_NORMAL;
-	    printf ("Switched back to normal tool.\n");
-	    }
-	 }
 
-      // [&] Show object numbers
-      else if (is.key == '&')
-         {
-         e.show_object_numbers = ! e.show_object_numbers;
-         RedrawMap = 1;
-         }
+	    // [&] Show object numbers
+	    else if (is.key == '&')
+	    {
+		e.show_object_numbers = !e.show_object_numbers;
+		RedrawMap = 1;
+	    }
 
-      // [%] Show things sprites
-      else if (is.key == '%')
-	 {
-	 e.show_things_sprites = ! e.show_things_sprites;
-	 e.show_things_squares = ! e.show_things_sprites;  // Not a typo !
-	 RedrawMap = 1;
-	 }
+	    // [%] Show things sprites
+	    else if (is.key == '%')
+	    {
+		e.show_things_sprites = !e.show_things_sprites;
+		e.show_things_squares = !e.show_things_sprites;	// Not a typo !
+		RedrawMap = 1;
+	    }
 
-      /* user likes music */
-      else if (is.key)
-	 {
-	 Beep ();
-	 }
-      }
+	    /* user likes music */
+	    else if (is.key)
+	    {
+		Beep();
+	    }
+	}
 
-   /*
-    *	Step 4 -- Misc. cruft
-    */
+	/*
+	 *   Step 4 -- Misc. cruft
+	 */
 
-   done :
+      done:
 
-   // Auto-scrolling: scroll the map automatically
-   // when the mouse pointer rests near the edge
-   // of the window.
-   // Scrolling is disabled when a pull-down menu
-   // is visible because it would be annoying to see
-   // the map scrolling while you're searching
-   // through the menus.
+	// Auto-scrolling: scroll the map automatically
+	// when the mouse pointer rests near the edge
+	// of the window.
+	// Scrolling is disabled when a pull-down menu
+	// is visible because it would be annoying to see
+	// the map scrolling while you're searching
+	// through the menus.
 
-   if (is.in_window
-      && autoscroll
-      && ! is.scroll_lock
-      && e.menubar->pulled_down () < 0)
-      {
-      unsigned distance;		// In pixels
+	if (is.in_window
+	    && autoscroll && !is.scroll_lock && e.menubar->pulled_down() < 0)
+	{
+	    unsigned distance;	// In pixels
 
 #define actual_move(total,dist) \
    ((int) (((total * autoscroll_amp / 100)\
    * ((double) (autoscroll_edge - dist) / autoscroll_edge))\
    / Scale))
 
-      distance = is.y;
-      // The reason for the second member of the condition
-      // is that we don't want to scroll when the user is
-      // simply reaching for a menu...
-      if (distance <= autoscroll_edge
-         && e.menubar->is_under_menubar_item (is.x) < 0)
-	 {
-	 if (MAPY (ScrCenterY) < /*MapMaxY*/ 20000)
+	    distance = is.y;
+	    // The reason for the second member of the condition
+	    // is that we don't want to scroll when the user is
+	    // simply reaching for a menu...
+	    if (distance <= autoscroll_edge
+		&& e.menubar->is_under_menubar_item(is.x) < 0)
 	    {
-	    OrigY += actual_move (ScrMaxY, distance);
-	    RedrawMap = 1;
+		if (MAPY(ScrCenterY) < /*MapMaxY */ 20000)
+		{
+		    OrigY += actual_move(ScrMaxY, distance);
+		    RedrawMap = 1;
+		}
 	    }
-	 }
 
-      distance = ScrMaxY - is.y;
-      if (distance <= autoscroll_edge)
-	 {
-	 if (MAPY (ScrCenterY) > /*MapMinY*/ -20000)
+	    distance = ScrMaxY - is.y;
+	    if (distance <= autoscroll_edge)
 	    {
-	    OrigY -= actual_move (ScrMaxY, distance);
-	    RedrawMap = 1;
+		if (MAPY(ScrCenterY) > /*MapMinY */ -20000)
+		{
+		    OrigY -= actual_move(ScrMaxY, distance);
+		    RedrawMap = 1;
+		}
 	    }
-	 }
 
-      distance = is.x;
-      if (distance <= autoscroll_edge)
-	 {
-	 if (MAPX (ScrCenterX) > /*MapMinX*/ -20000)
+	    distance = is.x;
+	    if (distance <= autoscroll_edge)
 	    {
-	    OrigX -= actual_move (ScrMaxX, distance);
-	    RedrawMap = 1;
+		if (MAPX(ScrCenterX) > /*MapMinX */ -20000)
+		{
+		    OrigX -= actual_move(ScrMaxX, distance);
+		    RedrawMap = 1;
+		}
 	    }
-	 }
 
-      // The reason for the second member of the condition
-      // is that we don't want to scroll when the user is
-      // simply reaching for the "Help" menu...
-      // Note: the ordinate "3 * FONTH" is of course not
-      // critical. It's just a rough approximation.
-      distance = ScrMaxX - is.x;
-      if (distance <= autoscroll_edge && (unsigned) is.y >= 3 * FONTH)
-	 {
-	 if (MAPX (ScrCenterX) < /*MapMaxX*/ 20000)
+	    // The reason for the second member of the condition
+	    // is that we don't want to scroll when the user is
+	    // simply reaching for the "Help" menu...
+	    // Note: the ordinate "3 * FONTH" is of course not
+	    // critical. It's just a rough approximation.
+	    distance = ScrMaxX - is.x;
+	    if (distance <= autoscroll_edge && (unsigned) is.y >= 3 * FONTH)
 	    {
-	    OrigX += actual_move (ScrMaxX, distance);
-	    RedrawMap = 1;
+		if (MAPX(ScrCenterX) < /*MapMaxX */ 20000)
+		{
+		    OrigX += actual_move(ScrMaxX, distance);
+		    RedrawMap = 1;
+		}
 	    }
-	 }
-      }
+	}
 
-   /*
-    *	Step 5 -- Process events that were generated
-    */
+	/*
+	 *   Step 5 -- Process events that were generated
+	 */
 
-   done2:
+      done2:
 
-   // Process events that were generated
-   if (has_event (YE_ZOOM_CHANGED) && ! e.grid_step_locked)
-      {
-      get_event ();
-      edit_grid_adapt (&e);
-      RedrawMap = 1;
-      }
+	// Process events that were generated
+	if (has_event(YE_ZOOM_CHANGED) && !e.grid_step_locked)
+	{
+	    get_event();
+	    edit_grid_adapt(&e);
+	    RedrawMap = 1;
+	}
 
-   if (RedrawMap)
-      e.edisplay->need_refresh ();
-   }
+	if (RedrawMap)
+	    e.edisplay->need_refresh();
+    }
 
-delete e.edisplay;
-delete e.selbox;
-delete e.menubar;
-for (size_t n = 0; n < MBM_HELP; n++)
-   delete e.mb_menu[n];
+    delete e.edisplay;
+    delete e.selbox;
+    delete e.menubar;
+    for (size_t n = 0; n < MBM_HELP; n++)
+	delete e.mb_menu[n];
 
-delete menu_linedef_flags;
-delete menu_thing_flags;
+    delete menu_linedef_flags;
+    delete menu_thing_flags;
 }
 
 
@@ -2455,28 +2541,24 @@
  *
  *	Return 0 on success, non-zero on failure.
  */
-static int zoom_fit (edit_t& e)
+static int zoom_fit(edit_t & e)
 {
-  // Empty level, 100% will be fine.
-  if (NumVertices == 0)
-    return edit_set_zoom (&e, 1.0);
+    // Empty level, 100% will be fine.
+    if (NumVertices == 0)
+	return edit_set_zoom(&e, 1.0);
+
+    update_level_bounds();
+
+    int MapSizeX = MapMaxX - MapMinX,
+        MapSizeY = MapMaxY - MapMinY;
 
-  update_level_bounds ();
-  double xzoom;
-  if (MapMaxX - MapMinX)
-     xzoom = .95 * ScrMaxX / (MapMaxX - MapMinX);
-  else
-     xzoom = 1;
-  double yzoom;
-  if (MapMaxY - MapMinY)
-     yzoom = .9 * ScrMaxY / (MapMaxY - MapMinY);
-  else
-     yzoom = 1;
-  int r = edit_set_zoom (&e, y_min (xzoom, yzoom));
-  if (r != 0)
-    return 1;
-  CenterMapAroundCoords ((MapMinX + MapMaxX) / 2, (MapMinY + MapMaxY) / 2);
-  return 0;
+    double xzoom = MapSizeX ? (0.95f * ScrMaxX / (double) MapSizeX) : 1,
+           yzoom = MapSizeY ? (0.9f * ScrMaxY / (double) MapSizeY) : 1;
+
+    int r = edit_set_zoom(&e, y_min(xzoom, yzoom));
+    if (r != 0)
+	return 1;
+
+    CenterMapAroundCoords((MapMinX + MapMaxX) / 2, (MapMinY + MapMaxY) / 2);
+    return 0;
 }
-
-
--- a/src/editloop.h	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/editloop.h	Sat Sep 24 14:16:04 2011 +0300
@@ -4,12 +4,8 @@
  */
 
 
-void EditorLoop (const char *); /* SWAP! */
-const char *SelectLevel (int levelno);
+void EditorLoop(const char *);	/* SWAP! */
+const char *SelectLevel(int levelno);
 int InputSectorType(int x0, int y0, int *number);
 int InputLinedefType(int x0, int y0, int *number);
 int InputThingType(int x0, int y0, int *number);
-
-
-
-
--- a/src/editobj.cc	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/editobj.cc	Sat Sep 24 14:16:04 2011 +0300
@@ -53,26 +53,28 @@
    (this is just like InputIntegerValue, but with a different prompt)
 */
 
-int InputObjectNumber (int x0, int y0, int objtype, int curobj)
+int InputObjectNumber(int x0, int y0, int objtype, int curobj)
 {
-int val, key;
-char prompt[80];
+    int val, key;
+    char prompt[80];
 
-sprintf (prompt, "Enter a %s number between 0 and %d:",
-   GetObjectTypeName (objtype), GetMaxObjectNum (objtype));
-if (x0 < 0)
-   x0 = (ScrMaxX - 25 - 8 * strlen (prompt)) / 2;
-if (y0 < 0)
-   y0 = (ScrMaxY - 55) / 2;
-DrawScreenBox3D (x0, y0, x0 + 25 + 8 * strlen (prompt), y0 + 55);
-set_colour (WHITE);
-DrawScreenText (x0 + 10, y0 + 8, prompt);
-val = curobj;
-while ((key
-       = InputInteger (x0 + 10, y0 + 28, &val, 0, GetMaxObjectNum (objtype)))
-       != YK_RETURN && key != YK_ESC)
-   Beep ();
-return val;
+    sprintf(prompt, "Enter a %s number between 0 and %d:",
+	    GetObjectTypeName(objtype), GetMaxObjectNum(objtype));
+    if (x0 < 0)
+	x0 = (ScrMaxX - 25 - 8 * strlen(prompt)) / 2;
+    if (y0 < 0)
+	y0 = (ScrMaxY - 55) / 2;
+    DrawScreenBox3D(x0, y0, x0 + 25 + 8 * strlen(prompt), y0 + 55);
+    set_colour(WHITE);
+    DrawScreenText(x0 + 10, y0 + 8, prompt);
+    val = curobj;
+    while ((key
+	    =
+	    InputInteger(x0 + 10, y0 + 28, &val, 0,
+			 GetMaxObjectNum(objtype))) != YK_RETURN
+	   && key != YK_ESC)
+	Beep();
+    return val;
 }
 
 
@@ -83,37 +85,39 @@
  *	and objid.num to whatever number the user entered. If
  *	the user hit [Esc], call nil() on objid.
  */
-void input_objid (Objid& objid, const Objid& init, int x0, int y0)
+void input_objid(Objid & objid, const Objid & init, int x0, int y0)
 {
-char prompt[80];
+    char prompt[80];
 
-sprintf (prompt, "Enter a %s number between 0 and %d:",
-   GetObjectTypeName (init.type), GetMaxObjectNum (init.type));
-if (x0 < 0)
-   x0 = (ScrMaxX - 25 - 8 * strlen (prompt)) / 2;
-if (y0 < 0)
-   y0 = (ScrMaxY - 55) / 2;
-DrawScreenBox3D (x0, y0, x0 + 25 + 8 * strlen (prompt), y0 + 55);
-set_colour (WHITE);
-DrawScreenText (x0 + 10, y0 + 8, prompt);
-int  num = init.num;
-int  key;
-while ((key
-       = InputInteger (x0 + 10, y0 + 28, &num, 0, GetMaxObjectNum (init.type)))
-       != YK_RETURN && key != YK_ESC)
-   Beep ();
-if (key == YK_ESC)
-   objid.nil ();
-else if (key == YK_RETURN)
-   {
-   objid.type = init.type;
-   objid.num  = num;
-   }
-else
-   {
-   nf_bug ("input_objid: bad key %d", (int) key);  // Can't happen
-   objid.nil ();
-   }
+    sprintf(prompt, "Enter a %s number between 0 and %d:",
+	    GetObjectTypeName(init.type), GetMaxObjectNum(init.type));
+    if (x0 < 0)
+	x0 = (ScrMaxX - 25 - 8 * strlen(prompt)) / 2;
+    if (y0 < 0)
+	y0 = (ScrMaxY - 55) / 2;
+    DrawScreenBox3D(x0, y0, x0 + 25 + 8 * strlen(prompt), y0 + 55);
+    set_colour(WHITE);
+    DrawScreenText(x0 + 10, y0 + 8, prompt);
+    int num = init.num;
+    int key;
+    while ((key
+	    =
+	    InputInteger(x0 + 10, y0 + 28, &num, 0,
+			 GetMaxObjectNum(init.type))) != YK_RETURN
+	   && key != YK_ESC)
+	Beep();
+    if (key == YK_ESC)
+	objid.nil();
+    else if (key == YK_RETURN)
+    {
+	objid.type = init.type;
+	objid.num = num;
+    }
+    else
+    {
+	nf_bug("input_objid: bad key %d", (int) key);	// Can't happen
+	objid.nil();
+    }
 }
 
 
@@ -121,62 +125,63 @@
    ask for an object number and display a warning message
 */
 
-int InputObjectXRef (int x0, int y0, int objtype, bool allownone, int curobj)
+int InputObjectXRef(int x0, int y0, int objtype, bool allownone, int curobj)
 {
-const char *const msg1 = "Warning: modifying the cross-references";
-const char *const msg2 = "between some objects may crash the game.";
-char prompt[80];
-size_t maxlen = 0;
-int width;
-int height;
+    const char *const msg1 = "Warning: modifying the cross-references";
+    const char *const msg2 = "between some objects may crash the game.";
+    char prompt[80];
+    size_t maxlen = 0;
+    int width;
+    int height;
 
 // Dimensions
-sprintf (prompt, "Enter a %s number between 0 and %d%c",
-  GetObjectTypeName (objtype),
-  GetMaxObjectNum (objtype), allownone ? ',' : ':');
-maxlen = 40;				// Why 40 ? -- AYM 2002-04-17
-if (strlen (prompt) > maxlen);
-   maxlen = strlen (prompt);
-if (strlen (msg1) > maxlen)
-   maxlen = strlen (msg1);
-if (strlen (msg2) > maxlen)
-   maxlen = strlen (msg2);
-int ya = 0 + BOX_BORDER + WIDE_VSPACING;
-int yb = ya;
-if (allownone)
-  yb += FONTH;
-int yc = yb + FONTH + WIDE_VSPACING;
+    sprintf(prompt, "Enter a %s number between 0 and %d%c",
+	    GetObjectTypeName(objtype),
+	    GetMaxObjectNum(objtype), allownone ? ',' : ':');
+    maxlen = 40;		// Why 40 ? -- AYM 2002-04-17
+    if (strlen(prompt) > maxlen);
+    maxlen = strlen(prompt);
+    if (strlen(msg1) > maxlen)
+	maxlen = strlen(msg1);
+    if (strlen(msg2) > maxlen)
+	maxlen = strlen(msg2);
+    int ya = 0 + BOX_BORDER + WIDE_VSPACING;
+    int yb = ya;
+    if (allownone)
+	yb += FONTH;
+    int yc = yb + FONTH + WIDE_VSPACING;
 // FIXME should query InputInteger() instead
-int yd = yc + 2 * HOLLOW_BORDER + 2 * NARROW_VSPACING + FONTH + WIDE_VSPACING;
-int ye = yd + FONTH;
-int yf = ye + FONTH + WIDE_VSPACING + BOX_BORDER;
-width  = 2 * BOX_BORDER + 2 * WIDE_HSPACING + maxlen * FONTW;
-height = yf - 0;
+    int yd =
+	yc + 2 * HOLLOW_BORDER + 2 * NARROW_VSPACING + FONTH + WIDE_VSPACING;
+    int ye = yd + FONTH;
+    int yf = ye + FONTH + WIDE_VSPACING + BOX_BORDER;
+    width = 2 * BOX_BORDER + 2 * WIDE_HSPACING + maxlen * FONTW;
+    height = yf - 0;
 
 // Position
-if (x0 < 0)
-   x0 = (ScrMaxX - width) / 2;
-if (y0 < 0)
-   y0 = (ScrMaxY - height) / 2;
+    if (x0 < 0)
+	x0 = (ScrMaxX - width) / 2;
+    if (y0 < 0)
+	y0 = (ScrMaxY - height) / 2;
 
-DrawScreenBox3D (x0, y0, x0 + width, y0 + height);
-set_colour (WHITE);
-int x = x0 + BOX_BORDER + WIDE_HSPACING;
-DrawScreenText (x, y0 + ya, prompt);
-if (allownone)
-   DrawScreenText (x, y0 + yb, "or -1 for none:");
-set_colour (LIGHTRED);
-DrawScreenText (x, y0 + yd, msg1);
-DrawScreenText (x, y0 + ye, msg2);
+    DrawScreenBox3D(x0, y0, x0 + width, y0 + height);
+    set_colour(WHITE);
+    int x = x0 + BOX_BORDER + WIDE_HSPACING;
+    DrawScreenText(x, y0 + ya, prompt);
+    if (allownone)
+	DrawScreenText(x, y0 + yb, "or -1 for none:");
+    set_colour(LIGHTRED);
+    DrawScreenText(x, y0 + yd, msg1);
+    DrawScreenText(x, y0 + ye, msg2);
 
-int val = curobj;
-int key;
-int min = allownone ? -1 : 0;
-int max = GetMaxObjectNum (objtype);
-while (key = InputInteger (x, y0 + yc, &val, min, max),
-       key != YK_RETURN && key != YK_ESC)
-   Beep ();
-return val;
+    int val = curobj;
+    int key;
+    int min = allownone ? -1 : 0;
+    int max = GetMaxObjectNum(objtype);
+    while (key = InputInteger(x, y0 + yc, &val, min, max),
+	   key != YK_RETURN && key != YK_ESC)
+	Beep();
+    return val;
 }
 
 
@@ -185,87 +190,94 @@
    ask for two vertex numbers and check for maximum valid number
 */
 
-bool Input2VertexNumbers (int x0, int y0, const char *prompt1, int *v1, int *v2)
+bool Input2VertexNumbers(int x0, int y0, const char *prompt1, int *v1,
+			 int *v2)
 {
-int  key;
-int  maxlen, first;
-char prompt2[80];
-int text_x0;
-int text_y0;
-int entry1_x0;
-int entry1_y0;
-int entry2_x0;
-int entry2_y0;
+    int key;
+    int maxlen, first;
+    char prompt2[80];
+    int text_x0;
+    int text_y0;
+    int entry1_x0;
+    int entry1_y0;
+    int entry2_x0;
+    int entry2_y0;
 // FIXME should let InputInteger() tell us
-const int entry_width  = 2 * HOLLOW_BORDER + 2 * NARROW_HSPACING + 7 * FONTW;
-const int entry_height = 2 * HOLLOW_BORDER + 2 * NARROW_VSPACING + FONTH;
+    const int entry_width =
+	2 * HOLLOW_BORDER + 2 * NARROW_HSPACING + 7 * FONTW;
+    const int entry_height = 2 * HOLLOW_BORDER + 2 * NARROW_VSPACING + FONTH;
 
-sprintf (prompt2, "Enter two numbers between 0 and %d:", NumVertices - 1);
+    sprintf(prompt2, "Enter two numbers between 0 and %d:", NumVertices - 1);
 
-if (strlen (prompt1) > strlen (prompt2))
-   maxlen = strlen (prompt1);
-else
-   maxlen = strlen (prompt2);
-if (x0 < 0)
-   x0 = (ScrMaxX - 25 - 8 * maxlen) / 2;
-if (y0 < 0)
-   y0 = (ScrMaxY - 75) / 2;
-text_x0 = x0 + BOX_BORDER + WIDE_HSPACING;
-text_y0 = y0 + BOX_BORDER + WIDE_VSPACING;
-entry1_x0 = text_x0 + 13 * FONTW;
-entry1_y0 = text_y0 + 3 * FONTH - HOLLOW_BORDER - NARROW_VSPACING;
-entry2_x0 = entry1_x0;
-entry2_y0 = text_y0 + 5 * FONTH - HOLLOW_BORDER - NARROW_VSPACING;
+    if (strlen(prompt1) > strlen(prompt2))
+	maxlen = strlen(prompt1);
+    else
+	maxlen = strlen(prompt2);
+    if (x0 < 0)
+	x0 = (ScrMaxX - 25 - 8 * maxlen) / 2;
+    if (y0 < 0)
+	y0 = (ScrMaxY - 75) / 2;
+    text_x0 = x0 + BOX_BORDER + WIDE_HSPACING;
+    text_y0 = y0 + BOX_BORDER + WIDE_VSPACING;
+    entry1_x0 = text_x0 + 13 * FONTW;
+    entry1_y0 = text_y0 + 3 * FONTH - HOLLOW_BORDER - NARROW_VSPACING;
+    entry2_x0 = entry1_x0;
+    entry2_y0 = text_y0 + 5 * FONTH - HOLLOW_BORDER - NARROW_VSPACING;
 
-DrawScreenBox3D (x0, y0,
-   x0 + 2 * BOX_BORDER + 2 * WIDE_HSPACING
-      + y_max (entry_width + 13 * FONTW, maxlen * FONTW) - 1,
-   y0 + 2 * BOX_BORDER + 2 * WIDE_VSPACING + 6 * FONTH - 1);
-set_colour (WHITE);
-DrawScreenText (text_x0, text_y0, prompt1);
-set_colour (WINFG);
-DrawScreenText (text_x0, text_y0 + FONTH, prompt2);
-DrawScreenText (text_x0, text_y0 + 3 * FONTH, "Start vertex");
-DrawScreenText (text_x0, text_y0 + 5 * FONTH, "End vertex");
+    DrawScreenBox3D(x0, y0,
+		    x0 + 2 * BOX_BORDER + 2 * WIDE_HSPACING
+		    + y_max(entry_width + 13 * FONTW, maxlen * FONTW) - 1,
+		    y0 + 2 * BOX_BORDER + 2 * WIDE_VSPACING + 6 * FONTH - 1);
+    set_colour(WHITE);
+    DrawScreenText(text_x0, text_y0, prompt1);
+    set_colour(WINFG);
+    DrawScreenText(text_x0, text_y0 + FONTH, prompt2);
+    DrawScreenText(text_x0, text_y0 + 3 * FONTH, "Start vertex");
+    DrawScreenText(text_x0, text_y0 + 5 * FONTH, "End vertex");
 
-first = 1;
-key = 0;
-for (;;)
-   {
-   DrawScreenBoxHollow (entry1_x0, entry1_y0,
-      entry1_x0 + entry_width - 1, entry1_y0 + entry_height - 1, BLACK);
-   set_colour (first ? WHITE : DARKGREY);
-   DrawScreenText (entry1_x0 + HOLLOW_BORDER + NARROW_HSPACING,
-      entry1_y0 + HOLLOW_BORDER + NARROW_VSPACING, "%d", *v1);
+    first = 1;
+    key = 0;
+    for (;;)
+    {
+	DrawScreenBoxHollow(entry1_x0, entry1_y0,
+			    entry1_x0 + entry_width - 1,
+			    entry1_y0 + entry_height - 1, BLACK);
+	set_colour(first ? WHITE : DARKGREY);
+	DrawScreenText(entry1_x0 + HOLLOW_BORDER + NARROW_HSPACING,
+		       entry1_y0 + HOLLOW_BORDER + NARROW_VSPACING, "%d",
+		       *v1);
 
-   DrawScreenBoxHollow (entry2_x0, entry2_y0,
-      entry2_x0 + entry_width - 1, entry2_y0 + entry_height - 1, BLACK);
-   set_colour (! first ? WHITE : DARKGREY);
-   DrawScreenText (entry2_x0 + HOLLOW_BORDER + NARROW_HSPACING,
-      entry2_y0 + HOLLOW_BORDER + NARROW_VSPACING, "%d", *v2);
+	DrawScreenBoxHollow(entry2_x0, entry2_y0,
+			    entry2_x0 + entry_width - 1,
+			    entry2_y0 + entry_height - 1, BLACK);
+	set_colour(!first ? WHITE : DARKGREY);
+	DrawScreenText(entry2_x0 + HOLLOW_BORDER + NARROW_HSPACING,
+		       entry2_y0 + HOLLOW_BORDER + NARROW_VSPACING, "%d",
+		       *v2);
 
-   if (first)
-      key = InputInteger (entry1_x0, entry1_y0, v1, 0, NumVertices - 1);
-   else
-      key = InputInteger (entry2_x0, entry2_y0, v2, 0, NumVertices - 1);
-   if (key==YK_LEFT || key==YK_RIGHT || key==YK_TAB || key==YK_BACKTAB)
-      first = !first;
-   else if (key == YK_ESC)
-      break;
-   else if (key == YK_RETURN)
-      {
-      if (first)
-	 first = 0;
-      else if (*v1 < 0 || *v1 >= NumVertices
-            || *v2 < 0 || *v2 >= NumVertices)
-	 Beep ();
-      else
-	 break;
-      }
-   else
-      Beep ();
-   }
-return (key == YK_RETURN);
+	if (first)
+	    key = InputInteger(entry1_x0, entry1_y0, v1, 0, NumVertices - 1);
+	else
+	    key = InputInteger(entry2_x0, entry2_y0, v2, 0, NumVertices - 1);
+	if (key == YK_LEFT || key == YK_RIGHT || key == YK_TAB
+	    || key == YK_BACKTAB)
+	    first = !first;
+	else if (key == YK_ESC)
+	    break;
+	else if (key == YK_RETURN)
+	{
+	    if (first)
+		first = 0;
+	    else if (*v1 < 0 || *v1 >= NumVertices
+		     || *v2 < 0 || *v2 >= NumVertices)
+		Beep();
+	    else
+		break;
+	}
+	else
+	    Beep();
+    }
+    return (key == YK_RETURN);
 }
 
 
@@ -274,83 +286,82 @@
    edit an object or a group of objects
 */
 
-void EditObjectsInfo (int x0, int y0, int objtype, SelPtr obj) /* SWAP! */
+void EditObjectsInfo(int x0, int y0, int objtype, SelPtr obj)	/* SWAP! */
 {
-char  *menustr[3];
-int    n, val;
-SelPtr cur;
-int    subwin_y0;
+    char *menustr[3];
+    int n, val;
+    SelPtr cur;
+    int subwin_y0;
 
-if (! obj)
-   return;
-switch (objtype)
-   {
-   case OBJ_THINGS:
-      ThingProperties (x0, y0, obj);
-      break;
+    if (!obj)
+	return;
+    switch (objtype)
+    {
+    case OBJ_THINGS:
+	ThingProperties(x0, y0, obj);
+	break;
 
-   case OBJ_VERTICES:
-      for (n = 0; n < 3; n++)
-	 menustr[n] = (char *) GetMemory (60);
-      sprintf (menustr[2], "Edit Vertex #%d", obj->objnum);
-      sprintf (menustr[0], "Change X position (Current: %d)",
-         Vertices[obj->objnum].x);
-      sprintf (menustr[1], "Change Y position (Current: %d)",
-         Vertices[obj->objnum].y);
+    case OBJ_VERTICES:
+	for (n = 0; n < 3; n++)
+	    menustr[n] = (char *) GetMemory(60);
+	sprintf(menustr[2], "Edit Vertex #%d", obj->objnum);
+	sprintf(menustr[0], "Change X position (Current: %d)",
+		Vertices[obj->objnum].x);
+	sprintf(menustr[1], "Change Y position (Current: %d)",
+		Vertices[obj->objnum].y);
 #ifdef OLDMEN
-      val = DisplayMenuArray (0, y0,
-         menustr[2], 2, NULL, menustr, NULL, NULL, NULL);
+	val = DisplayMenuArray(0, y0,
+			       menustr[2], 2, NULL, menustr, NULL, NULL,
+			       NULL);
 #else
-      val = vDisplayMenu (0, y0, menustr[2],
-         menustr[0], YK_, 0,
-         menustr[1], YK_, 0,
-	 NULL);
+	val = vDisplayMenu(0, y0, menustr[2],
+			   menustr[0], YK_, 0, menustr[1], YK_, 0, NULL);
 #endif
-      for (n = 0; n < 3; n++)
-	 FreeMemory (menustr[n]);
-      subwin_y0 = y0 + BOX_BORDER + (2 + val) * FONTH;
-      switch (val)
-	 {
-	 case 1:
-	    val = InputIntegerValue (x0 + 42, subwin_y0,
-               y_min (MapMinX, -10000),
-               y_max (MapMaxX, 10000),
-               Vertices[obj->objnum].x);
+	for (n = 0; n < 3; n++)
+	    FreeMemory(menustr[n]);
+	subwin_y0 = y0 + BOX_BORDER + (2 + val) * FONTH;
+	switch (val)
+	{
+	case 1:
+	    val = InputIntegerValue(x0 + 42, subwin_y0,
+				    y_min(MapMinX, -10000),
+				    y_max(MapMaxX, 10000),
+				    Vertices[obj->objnum].x);
 	    if (val != IIV_CANCEL)
-	       {
-	       n = val - Vertices[obj->objnum].x;
-	       for (cur = obj; cur; cur = cur->next)
-		  Vertices[cur->objnum].x += n;
-	       MadeChanges = 1;
-	       MadeMapChanges = 1;
-	       }
+	    {
+		n = val - Vertices[obj->objnum].x;
+		for (cur = obj; cur; cur = cur->next)
+		    Vertices[cur->objnum].x += n;
+		MadeChanges = 1;
+		MadeMapChanges = 1;
+	    }
 	    break;
 
-	 case 2:
-	    val = InputIntegerValue (x0 + 42, subwin_y0,
-               y_min (MapMinY, -10000),
-               y_max (MapMaxY, 10000),
-               Vertices[obj->objnum].y);
+	case 2:
+	    val = InputIntegerValue(x0 + 42, subwin_y0,
+				    y_min(MapMinY, -10000),
+				    y_max(MapMaxY, 10000),
+				    Vertices[obj->objnum].y);
 	    if (val != IIV_CANCEL)
-	       {
-	       n = val - Vertices[obj->objnum].y;
-	       for (cur = obj; cur; cur = cur->next)
-		  Vertices[cur->objnum].y += n;
-	       MadeChanges = 1;
-	       MadeMapChanges = 1;
-	       }
+	    {
+		n = val - Vertices[obj->objnum].y;
+		for (cur = obj; cur; cur = cur->next)
+		    Vertices[cur->objnum].y += n;
+		MadeChanges = 1;
+		MadeMapChanges = 1;
+	    }
 	    break;
-	 }
-      break;
+	}
+	break;
 
-   case OBJ_LINEDEFS:
-      LinedefProperties (x0, y0, obj);
-      break;
+    case OBJ_LINEDEFS:
+	LinedefProperties(x0, y0, obj);
+	break;
 
-   case OBJ_SECTORS:
-      SectorProperties (x0, y0, obj);
-      break;
-   }
+    case OBJ_SECTORS:
+	SectorProperties(x0, y0, obj);
+	break;
+    }
 }
 
 
@@ -358,116 +369,121 @@
    Yuck!  Dirty piece of code...
 */
 
-bool Input2Numbers (int x0, int y0, const char *name1, const char *name2,
-   int v1max, int v2max, int *v1, int *v2)
-{
-int  key;
-int  maxlen, first;
-bool ok;
-char prompt[80];
-// FIXME copied from InputInteger()...
-int  entry_width  = 2 * HOLLOW_BORDER + 2 * NARROW_HSPACING + 7 * FONTW;
-int  entry_height = 2 * HOLLOW_BORDER + 2 * NARROW_VSPACING + FONTH;
-
-y_snprintf (prompt, sizeof prompt, "Give the %s and %s for the object:",
-   name1, name2);
-maxlen = strlen (prompt);
-
-int title_x0       = BOX_BORDER + FONTW;
-int title_y0       = BOX_BORDER + FONTH / 2;
-int label1_x0      = title_x0;
-int label1_y0      = title_y0 + 2 * FONTH;
-int label2_x0      = title_x0 + (strlen (name1) + 2) * FONTW;
+bool Input2Numbers(int x0, int y0, const char *name1, const char *name2,
+		   int v1max, int v2max, int *v1, int *v2)
 {
-   int bound = label1_x0 + entry_width + int (FONTW);
-   if (label2_x0 < bound)
-      label2_x0 = bound;
-}
+    int key;
+    int maxlen, first;
+    bool ok;
+    char prompt[80];
+// FIXME copied from InputInteger()...
+    int entry_width = 2 * HOLLOW_BORDER + 2 * NARROW_HSPACING + 7 * FONTW;
+    int entry_height = 2 * HOLLOW_BORDER + 2 * NARROW_VSPACING + FONTH;
+
+    y_snprintf(prompt, sizeof prompt, "Give the %s and %s for the object:",
+	       name1, name2);
+    maxlen = strlen(prompt);
+
+    int title_x0 = BOX_BORDER + FONTW;
+    int title_y0 = BOX_BORDER + FONTH / 2;
+    int label1_x0 = title_x0;
+    int label1_y0 = title_y0 + 2 * FONTH;
+    int label2_x0 = title_x0 + (strlen(name1) + 2) * FONTW;
+    {
+	int bound = label1_x0 + entry_width + int (FONTW);
+	if (label2_x0 < bound)
+	    label2_x0 = bound;
+    }
 // FIXME Assuming the range is not longer than the name
-int label2_y0      = label1_y0;
-int entry1_out_x0  = label1_x0;
-int entry1_out_y0  = label1_y0 + 3 * FONTH / 2;
-int entry1_text_x0 = entry1_out_x0 + HOLLOW_BORDER + NARROW_HSPACING;
-int entry1_text_y0 = entry1_out_y0 + HOLLOW_BORDER + NARROW_VSPACING;
-int entry1_out_x1  = entry1_out_x0 + entry_width - 1;
-int entry1_out_y1  = entry1_out_y0 + entry_height - 1;
-int entry2_out_x0  = label2_x0;
-int entry2_out_y0  = label2_y0 + 3 * FONTH / 2;
-int entry2_text_x0 = entry2_out_x0 + HOLLOW_BORDER + NARROW_HSPACING;
-int entry2_text_y0 = entry2_out_y0 + HOLLOW_BORDER + NARROW_VSPACING;
-int entry2_out_x1  = entry2_out_x0 + entry_width - 1;
-int entry2_out_y1  = entry2_out_y0 + entry_height - 1;
-int range1_x0      = entry1_out_x0;
-int range1_y0      = entry1_out_y1 + FONTH / 2;
-int range2_x0      = entry2_out_x0;
-int range2_y0      = entry2_out_y1 + FONTH / 2;
-int window_x1      = entry2_out_x1 + FONTW + BOX_BORDER;
-int window_y1      = range1_y0 + 3 * FONTH / 2 + BOX_BORDER;
-{
-   int bound = 2 * BOX_BORDER + (maxlen + 2) * int (FONTW);
-   if (window_x1 < bound)
-      window_x1 = bound;
-}
+    int label2_y0 = label1_y0;
+    int entry1_out_x0 = label1_x0;
+    int entry1_out_y0 = label1_y0 + 3 * FONTH / 2;
+    int entry1_text_x0 = entry1_out_x0 + HOLLOW_BORDER + NARROW_HSPACING;
+    int entry1_text_y0 = entry1_out_y0 + HOLLOW_BORDER + NARROW_VSPACING;
+    int entry1_out_x1 = entry1_out_x0 + entry_width - 1;
+    int entry1_out_y1 = entry1_out_y0 + entry_height - 1;
+    int entry2_out_x0 = label2_x0;
+    int entry2_out_y0 = label2_y0 + 3 * FONTH / 2;
+    int entry2_text_x0 = entry2_out_x0 + HOLLOW_BORDER + NARROW_HSPACING;
+    int entry2_text_y0 = entry2_out_y0 + HOLLOW_BORDER + NARROW_VSPACING;
+    int entry2_out_x1 = entry2_out_x0 + entry_width - 1;
+    int entry2_out_y1 = entry2_out_y0 + entry_height - 1;
+    int range1_x0 = entry1_out_x0;
+    int range1_y0 = entry1_out_y1 + FONTH / 2;
+    int range2_x0 = entry2_out_x0;
+    int range2_y0 = entry2_out_y1 + FONTH / 2;
+    int window_x1 = entry2_out_x1 + FONTW + BOX_BORDER;
+    int window_y1 = range1_y0 + 3 * FONTH / 2 + BOX_BORDER;
+    {
+	int bound = 2 * BOX_BORDER + (maxlen + 2) * int (FONTW);
+	if (window_x1 < bound)
+	    window_x1 = bound;
+    }
+
+    if (x0 < 0)
+	x0 = (ScrMaxX - window_x1) / 2;
+    if (y0 < 0)
+	y0 = (ScrMaxY - window_y1) / 2;
 
-if (x0 < 0)
-   x0 = (ScrMaxX - window_x1) / 2;
-if (y0 < 0)
-   y0 = (ScrMaxY - window_y1) / 2;
-
-DrawScreenBox3D (x0, y0, x0 + window_x1, y0 + window_y1);
-set_colour     (WHITE);
-DrawScreenText (x0 + title_x0,  y0 + title_x0,  prompt);
-DrawScreenText (x0 + label1_x0, y0 + label1_y0, name1);
-DrawScreenText (x0 + label2_x0, y0 + label2_y0, name2);
-DrawScreenText (x0 + range1_x0, y0 + range1_y0, "(0-%d)", v1max);
-DrawScreenText (x0 + range2_x0, y0 + range2_y0, "(0-%d)", v2max);
+    DrawScreenBox3D(x0, y0, x0 + window_x1, y0 + window_y1);
+    set_colour(WHITE);
+    DrawScreenText(x0 + title_x0, y0 + title_x0, prompt);
+    DrawScreenText(x0 + label1_x0, y0 + label1_y0, name1);
+    DrawScreenText(x0 + label2_x0, y0 + label2_y0, name2);
+    DrawScreenText(x0 + range1_x0, y0 + range1_y0, "(0-%d)", v1max);
+    DrawScreenText(x0 + range2_x0, y0 + range2_y0, "(0-%d)", v2max);
 
-first = 1;
-key = 0;
-for (;;)
-   {
-   ok = true;
-   DrawScreenBoxHollow (x0 + entry1_out_x0, y0 + entry1_out_y0,
-      x0 + entry1_out_x1, y0 + entry1_out_y1, BLACK);
-   if (*v1 < 0 || *v1 > v1max)
-      {
-      set_colour (DARKGREY);
-      ok = false;
-      }
-   else
-      set_colour (LIGHTGREY);
-   DrawScreenText (x0 + entry1_text_x0, y0 + entry1_text_y0, "%d", *v1);
-   DrawScreenBoxHollow (x0 + entry2_out_x0, y0 + entry2_out_y0,
-      x0 + entry2_out_x1, y0 + entry2_out_y1, BLACK);
-   if (*v2 < 0 || *v2 > v2max)
-      {
-      set_colour (DARKGREY);
-      ok = false;
-      }
-   else
-      set_colour (LIGHTGREY);
-   DrawScreenText (x0 + entry2_text_x0, y0 + entry2_text_y0, "%d", *v2);
-   if (first)
-      key = InputInteger (x0 + entry1_out_x0, y0 + entry1_out_y0, v1, 0, v1max);
-   else
-      key = InputInteger (x0 + entry2_out_x0, y0 + entry2_out_y0, v2, 0, v2max);
-   if (key==YK_LEFT || key==YK_RIGHT || key==YK_TAB || key==YK_BACKTAB)
-      first = !first;
-   else if (key == YK_ESC)
-      break;
-   else if (key == YK_RETURN)
-      {
-      if (first)
-	 first = 0;
-      else if (ok)
-	 break;
-      else
-	 Beep ();
-      }
-   else
-      Beep ();
-   }
-return (key == YK_RETURN);
+    first = 1;
+    key = 0;
+    for (;;)
+    {
+	ok = true;
+	DrawScreenBoxHollow(x0 + entry1_out_x0, y0 + entry1_out_y0,
+			    x0 + entry1_out_x1, y0 + entry1_out_y1, BLACK);
+	if (*v1 < 0 || *v1 > v1max)
+	{
+	    set_colour(DARKGREY);
+	    ok = false;
+	}
+	else
+	    set_colour(LIGHTGREY);
+	DrawScreenText(x0 + entry1_text_x0, y0 + entry1_text_y0, "%d", *v1);
+	DrawScreenBoxHollow(x0 + entry2_out_x0, y0 + entry2_out_y0,
+			    x0 + entry2_out_x1, y0 + entry2_out_y1, BLACK);
+	if (*v2 < 0 || *v2 > v2max)
+	{
+	    set_colour(DARKGREY);
+	    ok = false;
+	}
+	else
+	    set_colour(LIGHTGREY);
+	DrawScreenText(x0 + entry2_text_x0, y0 + entry2_text_y0, "%d", *v2);
+	if (first)
+	    key =
+		InputInteger(x0 + entry1_out_x0, y0 + entry1_out_y0, v1, 0,
+			     v1max);
+	else
+	    key =
+		InputInteger(x0 + entry2_out_x0, y0 + entry2_out_y0, v2, 0,
+			     v2max);
+	if (key == YK_LEFT || key == YK_RIGHT || key == YK_TAB
+	    || key == YK_BACKTAB)
+	    first = !first;
+	else if (key == YK_ESC)
+	    break;
+	else if (key == YK_RETURN)
+	{
+	    if (first)
+		first = 0;
+	    else if (ok)
+		break;
+	    else
+		Beep();
+	}
+	else
+	    Beep();
+    }
+    return (key == YK_RETURN);
 }
 
 
@@ -476,163 +492,164 @@
    insert a standard object at given position
 */
 
-void InsertStandardObject (int xpos, int ypos, int choice) /* SWAP! */
+void InsertStandardObject(int xpos, int ypos, int choice)	/* SWAP! */
 {
-int sector;
-int n;
-int a, b;
+    int sector;
+    int n;
+    int a, b;
 
 /* are we inside a Sector? */
-Objid o;
-GetCurObject (o, OBJ_SECTORS, xpos, ypos);
-sector = o.num;
+    Objid o;
+    GetCurObject(o, OBJ_SECTORS, xpos, ypos);
+    sector = o.num;
 
 /* !!!! Should also check for overlapping objects (sectors) !!!! */
-switch (choice)
-   {
-   case 1:
-      a = 256;
-      b = 128;
-      if (Input2Numbers (-1, -1, "Width", "Height", 2000, 2000, &a, &b))
-	 {
-	 if (a < 8)
-	    a = 8;
-	 if (b < 8)
-	    b = 8;
-	 xpos = xpos - a / 2;
-	 ypos = ypos - b / 2;
-	 InsertObject (OBJ_VERTICES, -1, xpos, ypos);
-	 InsertObject (OBJ_VERTICES, -1, xpos + a, ypos);
-	 InsertObject (OBJ_VERTICES, -1, xpos + a, ypos + b);
-	 InsertObject (OBJ_VERTICES, -1, xpos, ypos + b);
-	 if (sector < 0)
-	    InsertObject (OBJ_SECTORS, -1, 0, 0);
-	 for (n = 0; n < 4; n++)
+    switch (choice)
+    {
+    case 1:
+	a = 256;
+	b = 128;
+	if (Input2Numbers(-1, -1, "Width", "Height", 2000, 2000, &a, &b))
+	{
+	    if (a < 8)
+		a = 8;
+	    if (b < 8)
+		b = 8;
+	    xpos = xpos - a / 2;
+	    ypos = ypos - b / 2;
+	    InsertObject(OBJ_VERTICES, -1, xpos, ypos);
+	    InsertObject(OBJ_VERTICES, -1, xpos + a, ypos);
+	    InsertObject(OBJ_VERTICES, -1, xpos + a, ypos + b);
+	    InsertObject(OBJ_VERTICES, -1, xpos, ypos + b);
+	    if (sector < 0)
+		InsertObject(OBJ_SECTORS, -1, 0, 0);
+	    for (n = 0; n < 4; n++)
 	    {
-	    InsertObject (OBJ_LINEDEFS, -1, 0, 0);
-	    LineDefs[NumLineDefs - 1].sidedef1 = NumSideDefs;
-	    InsertObject (OBJ_SIDEDEFS, -1, 0, 0);
+		InsertObject(OBJ_LINEDEFS, -1, 0, 0);
+		LineDefs[NumLineDefs - 1].sidedef1 = NumSideDefs;
+		InsertObject(OBJ_SIDEDEFS, -1, 0, 0);
+		if (sector >= 0)
+		    SideDefs[NumSideDefs - 1].sector = sector;
+	    }
 	    if (sector >= 0)
-	       SideDefs[NumSideDefs - 1].sector = sector;
-	    }
-	 if (sector >= 0)
 	    {
-	    LineDefs[NumLineDefs - 4].start = NumVertices - 4;
-	    LineDefs[NumLineDefs - 4].end = NumVertices - 3;
-	    LineDefs[NumLineDefs - 3].start = NumVertices - 3;
-	    LineDefs[NumLineDefs - 3].end = NumVertices - 2;
-	    LineDefs[NumLineDefs - 2].start = NumVertices - 2;
-	    LineDefs[NumLineDefs - 2].end = NumVertices - 1;
-	    LineDefs[NumLineDefs - 1].start = NumVertices - 1;
-	    LineDefs[NumLineDefs - 1].end = NumVertices - 4;
-	    }
-	 else
-	    {
-	    LineDefs[NumLineDefs - 4].start = NumVertices - 1;
-	    LineDefs[NumLineDefs - 4].end = NumVertices - 2;
-	    LineDefs[NumLineDefs - 3].start = NumVertices - 2;
-	    LineDefs[NumLineDefs - 3].end = NumVertices - 3;
-	    LineDefs[NumLineDefs - 2].start = NumVertices - 3;
-	    LineDefs[NumLineDefs - 2].end = NumVertices - 4;
-	    LineDefs[NumLineDefs - 1].start = NumVertices - 4;
-	    LineDefs[NumLineDefs - 1].end = NumVertices - 1;
+		LineDefs[NumLineDefs - 4].start = NumVertices - 4;
+		LineDefs[NumLineDefs - 4].end = NumVertices - 3;
+		LineDefs[NumLineDefs - 3].start = NumVertices - 3;
+		LineDefs[NumLineDefs - 3].end = NumVertices - 2;
+		LineDefs[NumLineDefs - 2].start = NumVertices - 2;
+		LineDefs[NumLineDefs - 2].end = NumVertices - 1;
+		LineDefs[NumLineDefs - 1].start = NumVertices - 1;
+		LineDefs[NumLineDefs - 1].end = NumVertices - 4;
 	    }
-	 }
-      break;
-   case 2:
-      a = 8;
-      b = 128;
-      if (Input2Numbers (-1, -1, "Number of sides", "Radius", 32, 2000, &a, &b))
-	 {
-	 if (a < 3)
-	    a = 3;
-	 if (b < 8)
-	    b = 8;
-	 InsertPolygonVertices (xpos, ypos, a, b);
-	 if (sector < 0)
-	    InsertObject (OBJ_SECTORS, -1, 0, 0);
-	 for (n = 0; n < a; n++)
+	    else
 	    {
-	    InsertObject (OBJ_LINEDEFS, -1, 0, 0);
-	    LineDefs[NumLineDefs - 1].sidedef1 = NumSideDefs;
-	    InsertObject (OBJ_SIDEDEFS, -1, 0, 0);
-	    if (sector >= 0)
-	       SideDefs[NumSideDefs - 1].sector = sector;
+		LineDefs[NumLineDefs - 4].start = NumVertices - 1;
+		LineDefs[NumLineDefs - 4].end = NumVertices - 2;
+		LineDefs[NumLineDefs - 3].start = NumVertices - 2;
+		LineDefs[NumLineDefs - 3].end = NumVertices - 3;
+		LineDefs[NumLineDefs - 2].start = NumVertices - 3;
+		LineDefs[NumLineDefs - 2].end = NumVertices - 4;
+		LineDefs[NumLineDefs - 1].start = NumVertices - 4;
+		LineDefs[NumLineDefs - 1].end = NumVertices - 1;
 	    }
-	 if (sector >= 0)
+	}
+	break;
+    case 2:
+	a = 8;
+	b = 128;
+	if (Input2Numbers
+	    (-1, -1, "Number of sides", "Radius", 32, 2000, &a, &b))
+	{
+	    if (a < 3)
+		a = 3;
+	    if (b < 8)
+		b = 8;
+	    InsertPolygonVertices(xpos, ypos, a, b);
+	    if (sector < 0)
+		InsertObject(OBJ_SECTORS, -1, 0, 0);
+	    for (n = 0; n < a; n++)
 	    {
-	    LineDefs[NumLineDefs - 1].start = NumVertices - 1;
-	    LineDefs[NumLineDefs - 1].end = NumVertices - a;
-	    for (n = 2; n <= a; n++)
-	       {
-	       LineDefs[NumLineDefs - n].start = NumVertices - n;
-	       LineDefs[NumLineDefs - n].end = NumVertices - n + 1;
-	       }
-	    }
-	 else
-	    {
-	    LineDefs[NumLineDefs - 1].start = NumVertices - a;
-	    LineDefs[NumLineDefs - 1].end = NumVertices - 1;
-	    for (n = 2; n <= a; n++)
-	       {
-	       LineDefs[NumLineDefs - n].start = NumVertices - n + 1;
-	       LineDefs[NumLineDefs - n].end = NumVertices - n;
-	       }
+		InsertObject(OBJ_LINEDEFS, -1, 0, 0);
+		LineDefs[NumLineDefs - 1].sidedef1 = NumSideDefs;
+		InsertObject(OBJ_SIDEDEFS, -1, 0, 0);
+		if (sector >= 0)
+		    SideDefs[NumSideDefs - 1].sector = sector;
 	    }
-	 }
-      break;
-   case 3:
-   /*
-      a = 6;
-      b = 16;
-      if (Input2Numbers (-1, -1, "Number of steps", "Step height", 32, 48, &a, &b))
-	 {
-	 if (a < 2)
-	    a = 2;
-	 n = Sectors[sector].ceilh;
-	 h = Sectors[sector].floorh;
-	 if (a * b < n - h)
+	    if (sector >= 0)
 	    {
-	    Beep ();
-	    Notify (-1, -1, "The stairs are too high for this Sector", 0);
-	    return;
+		LineDefs[NumLineDefs - 1].start = NumVertices - 1;
+		LineDefs[NumLineDefs - 1].end = NumVertices - a;
+		for (n = 2; n <= a; n++)
+		{
+		    LineDefs[NumLineDefs - n].start = NumVertices - n;
+		    LineDefs[NumLineDefs - n].end = NumVertices - n + 1;
+		}
+	    }
+	    else
+	    {
+		LineDefs[NumLineDefs - 1].start = NumVertices - a;
+		LineDefs[NumLineDefs - 1].end = NumVertices - 1;
+		for (n = 2; n <= a; n++)
+		{
+		    LineDefs[NumLineDefs - n].start = NumVertices - n + 1;
+		    LineDefs[NumLineDefs - n].end = NumVertices - n;
+		}
 	    }
-	 xpos = xpos - 32;
-	 ypos = ypos - 32 * a;
-	 for (n = 0; n < a; n++)
-	    {
-	    InsertObject (OBJ_VERTICES, -1, xpos, ypos);
-	    InsertObject (OBJ_VERTICES, -1, xpos + 64, ypos);
-	    InsertObject (OBJ_VERTICES, -1, xpos + 64, ypos + 64);
-	    InsertObject (OBJ_VERTICES, -1, xpos, ypos + 64);
-	    ypos += 64;
-	    InsertObject (OBJ_SECTORS, sector, 0, 0);
-	    h += b;
-	    Sectors[NumSectors - 1].floorh = h;
+	}
+	break;
+    case 3:
+	/*
+	   a = 6;
+	   b = 16;
+	   if (Input2Numbers (-1, -1, "Number of steps", "Step height", 32, 48, &a, &b))
+	   {
+	   if (a < 2)
+	   a = 2;
+	   n = Sectors[sector].ceilh;
+	   h = Sectors[sector].floorh;
+	   if (a * b < n - h)
+	   {
+	   Beep ();
+	   Notify (-1, -1, "The stairs are too high for this Sector", 0);
+	   return;
+	   }
+	   xpos = xpos - 32;
+	   ypos = ypos - 32 * a;
+	   for (n = 0; n < a; n++)
+	   {
+	   InsertObject (OBJ_VERTICES, -1, xpos, ypos);
+	   InsertObject (OBJ_VERTICES, -1, xpos + 64, ypos);
+	   InsertObject (OBJ_VERTICES, -1, xpos + 64, ypos + 64);
+	   InsertObject (OBJ_VERTICES, -1, xpos, ypos + 64);
+	   ypos += 64;
+	   InsertObject (OBJ_SECTORS, sector, 0, 0);
+	   h += b;
+	   Sectors[NumSectors - 1].floorh = h;
 
-	    InsertObject (OBJ_LINEDEFS, -1, 0, 0);
-	    LineDefs[NumLineDefs - 1].sidedef1 = NumSideDefs;
-	    LineDefs[NumLineDefs - 1].sidedef2 = NumSideDefs + 1;
-	    InsertObject (OBJ_SIDEDEFS, -1, 0, 0);
-	    SideDefs[NumSideDefs - 1].sector = sector;
-	    InsertObject (OBJ_SIDEDEFS, -1, 0, 0);
+	   InsertObject (OBJ_LINEDEFS, -1, 0, 0);
+	   LineDefs[NumLineDefs - 1].sidedef1 = NumSideDefs;
+	   LineDefs[NumLineDefs - 1].sidedef2 = NumSideDefs + 1;
+	   InsertObject (OBJ_SIDEDEFS, -1, 0, 0);
+	   SideDefs[NumSideDefs - 1].sector = sector;
+	   InsertObject (OBJ_SIDEDEFS, -1, 0, 0);
 
-	    LineDefs[NumLineDefs - 4].start = NumVertices - 4;
-	    LineDefs[NumLineDefs - 4].end = NumVertices - 3;
-	    LineDefs[NumLineDefs - 3].start = NumVertices - 3;
-	    LineDefs[NumLineDefs - 3].end = NumVertices - 2;
-	    LineDefs[NumLineDefs - 2].start = NumVertices - 2;
-	    LineDefs[NumLineDefs - 2].end = NumVertices - 1;
-	    LineDefs[NumLineDefs - 1].start = NumVertices - 1;
-	    LineDefs[NumLineDefs - 1].end = NumVertices - 4;
+	   LineDefs[NumLineDefs - 4].start = NumVertices - 4;
+	   LineDefs[NumLineDefs - 4].end = NumVertices - 3;
+	   LineDefs[NumLineDefs - 3].start = NumVertices - 3;
+	   LineDefs[NumLineDefs - 3].end = NumVertices - 2;
+	   LineDefs[NumLineDefs - 2].start = NumVertices - 2;
+	   LineDefs[NumLineDefs - 2].end = NumVertices - 1;
+	   LineDefs[NumLineDefs - 1].start = NumVertices - 1;
+	   LineDefs[NumLineDefs - 1].end = NumVertices - 4;
 	   }
-	 }
-      break;
-   */
-   case 4:
-      NotImplemented ();
-      break;
-   }
+	   }
+	   break;
+	 */
+    case 4:
+	NotImplemented();
+	break;
+    }
 }
 
 
@@ -641,376 +658,375 @@
    menu of miscellaneous operations
 */
 
-void MiscOperations (int objtype, SelPtr *list, int val) /* SWAP! */
+void MiscOperations(int objtype, SelPtr * list, int val)	/* SWAP! */
 {
-char   msg[80];
-int    angle, scale;
+    char msg[80];
+    int angle, scale;
 
-if (val > 1 && ! *list)
-   {
-   Beep ();
-   sprintf (msg, "You must select at least one %s", GetObjectTypeName (objtype));
-   Notify (-1, -1, msg, 0);
-   return;
-   }
+    if (val > 1 && !*list)
+    {
+	Beep();
+	sprintf(msg, "You must select at least one %s",
+		GetObjectTypeName(objtype));
+	Notify(-1, -1, msg, 0);
+	return;
+    }
 
 /* I think this switch statement deserves a prize for "worst
    gratuitous obfuscation" or something. -- AYM 2000-11-07 */
-switch (val)
-   {
-   case 1:
-      // * -> First free tag number
-      sprintf (msg, "First free tag number: %d", FindFreeTag ());
-      Notify (-1, -1, msg, 0);
-      break;
+    switch (val)
+    {
+    case 1:
+	// * -> First free tag number
+	sprintf(msg, "First free tag number: %d", FindFreeTag());
+	Notify(-1, -1, msg, 0);
+	break;
 
-   case 2:
-      // * -> Rotate and scale
-      if ((objtype == OBJ_THINGS
-         || objtype == OBJ_VERTICES) && ! (*list)->next)
-	 {
-	 Beep ();
-	 sprintf (msg, "You must select more than one %s",
-            GetObjectTypeName (objtype));
-	 Notify (-1, -1, msg, 0);
-	 return;
-	 }
-      angle = 0;
-      scale = 100;
-      if (Input2Numbers (-1, -1, "rotation angle (°)", "scale (%)",
-         360, 1000, &angle, &scale))
-	 RotateAndScaleObjects (objtype, *list, (double) angle * 0.0174533,
-            (double) scale * 0.01);
-      break;
+    case 2:
+	// * -> Rotate and scale
+	if ((objtype == OBJ_THINGS
+	     || objtype == OBJ_VERTICES) && !(*list)->next)
+	{
+	    Beep();
+	    sprintf(msg, "You must select more than one %s",
+		    GetObjectTypeName(objtype));
+	    Notify(-1, -1, msg, 0);
+	    return;
+	}
+	angle = 0;
+	scale = 100;
+	if (Input2Numbers(-1, -1, "rotation angle (°)", "scale (%)",
+			  360, 1000, &angle, &scale))
+	    RotateAndScaleObjects(objtype, *list, (double) angle * 0.0174533,
+				  (double) scale * 0.01);
+	break;
 
-   case 3:
-      // Linedef -> Split
-      if (objtype == OBJ_LINEDEFS)
-	 {
-	 SplitLineDefs (*list);
-	 }
-      // Sector -> Make door from sector
-      else if (objtype == OBJ_SECTORS)
-	 {
-	 if ((*list)->next)
+    case 3:
+	// Linedef -> Split
+	if (objtype == OBJ_LINEDEFS)
+	{
+	    SplitLineDefs(*list);
+	}
+	// Sector -> Make door from sector
+	else if (objtype == OBJ_SECTORS)
+	{
+	    if ((*list)->next)
 	    {
-	    Beep ();
-	    Notify (-1, -1, "You must select exactly one sector", 0);
+		Beep();
+		Notify(-1, -1, "You must select exactly one sector", 0);
 	    }
-	 else
+	    else
 	    {
-	    MakeDoorFromSector ((*list)->objnum);
+		MakeDoorFromSector((*list)->objnum);
 	    }
-	 }
-      // Thing -> Spin 45° clockwise
-      else if (objtype == OBJ_THINGS)
-	 {
-         spin_things (*list, -45);
-	 }
-      // Vertex -> Delete and join linedefs
-      else if (objtype == OBJ_VERTICES)
-	 {
-	 DeleteVerticesJoinLineDefs (*list);
-	 ForgetSelection (list);
-	 }
-      break;
+	}
+	// Thing -> Spin 45° clockwise
+	else if (objtype == OBJ_THINGS)
+	{
+	    spin_things(*list, -45);
+	}
+	// Vertex -> Delete and join linedefs
+	else if (objtype == OBJ_VERTICES)
+	{
+	    DeleteVerticesJoinLineDefs(*list);
+	    ForgetSelection(list);
+	}
+	break;
 
-   case 4:
-      // Linedef -> Split linedefs and sector
-      if (objtype == OBJ_LINEDEFS)
-	 {
-	 if (! (*list)->next || (*list)->next->next)
-	    {
-	    Beep ();
-	    Notify (-1, -1, "You must select exactly two linedefs", 0);
-	    }
-	 else
+    case 4:
+	// Linedef -> Split linedefs and sector
+	if (objtype == OBJ_LINEDEFS)
+	{
+	    if (!(*list)->next || (*list)->next->next)
 	    {
-	    SplitLineDefsAndSector ((*list)->next->objnum, (*list)->objnum);
-	    ForgetSelection (list);
+		Beep();
+		Notify(-1, -1, "You must select exactly two linedefs", 0);
 	    }
-	 }
-      // Sector -> Make lift from sector
-      else if (objtype == OBJ_SECTORS)
-	 {
-	 if ((*list)->next)
+	    else
 	    {
-	    Beep ();
-	    Notify (-1, -1, "You must select exactly one Sector", 0);
+		SplitLineDefsAndSector((*list)->next->objnum,
+				       (*list)->objnum);
+		ForgetSelection(list);
 	    }
-	 else
+	}
+	// Sector -> Make lift from sector
+	else if (objtype == OBJ_SECTORS)
+	{
+	    if ((*list)->next)
 	    {
-	    MakeLiftFromSector ((*list)->objnum);
+		Beep();
+		Notify(-1, -1, "You must select exactly one Sector", 0);
+	    }
+	    else
+	    {
+		MakeLiftFromSector((*list)->objnum);
 	    }
-	 }
-      // Thing -> Spin 45° counter-clockwise
-      else if (objtype == OBJ_THINGS)
-         spin_things (*list, 45);
-      // Vertex -> Merge
-      else if (objtype == OBJ_VERTICES)
-	 {
-	 MergeVertices (list);
-	 }
-      break;
+	}
+	// Thing -> Spin 45° counter-clockwise
+	else if (objtype == OBJ_THINGS)
+	    spin_things(*list, 45);
+	// Vertex -> Merge
+	else if (objtype == OBJ_VERTICES)
+	{
+	    MergeVertices(list);
+	}
+	break;
 
-   case 5:
-      // Linedef -> Delete linedefs and join sectors
-      if (objtype == OBJ_LINEDEFS)
-	 {
-	 DeleteLineDefsJoinSectors (list);
-	 }
-      // Sector -> Distribute sector floor heights
-      else if (objtype == OBJ_SECTORS)
-	 {
-	 if (! (*list)->next || ! (*list)->next->next)
+    case 5:
+	// Linedef -> Delete linedefs and join sectors
+	if (objtype == OBJ_LINEDEFS)
+	{
+	    DeleteLineDefsJoinSectors(list);
+	}
+	// Sector -> Distribute sector floor heights
+	else if (objtype == OBJ_SECTORS)
+	{
+	    if (!(*list)->next || !(*list)->next->next)
 	    {
-	    Beep ();
-	    Notify (-1, -1, "You must select three or more sectors", 0);
+		Beep();
+		Notify(-1, -1, "You must select three or more sectors", 0);
 	    }
-	 else
-	    {
-	    DistributeSectorFloors (*list);
-	    }
-	 }
-      // Thing -> Mirror horizontally
-      else if (objtype == OBJ_THINGS)
-         {
-	 flip_mirror (*list, OBJ_THINGS, 'm');
-	 }
-      // Vertex -> Add linedef and split sector
-      else if (objtype == OBJ_VERTICES)
-	 {
-	 if (! (*list)->next || (*list)->next->next)
+	    else
 	    {
-	    Beep ();
-	    Notify (-1, -1, "You must select exactly two vertices", 0);
+		DistributeSectorFloors(*list);
 	    }
-	 else
+	}
+	// Thing -> Mirror horizontally
+	else if (objtype == OBJ_THINGS)
+	{
+	    flip_mirror(*list, OBJ_THINGS, 'm');
+	}
+	// Vertex -> Add linedef and split sector
+	else if (objtype == OBJ_VERTICES)
+	{
+	    if (!(*list)->next || (*list)->next->next)
 	    {
-	    SplitSector ((*list)->next->objnum, (*list)->objnum);
-	    ForgetSelection (list);
+		Beep();
+		Notify(-1, -1, "You must select exactly two vertices", 0);
 	    }
-	 }
-      break;
+	    else
+	    {
+		SplitSector((*list)->next->objnum, (*list)->objnum);
+		ForgetSelection(list);
+	    }
+	}
+	break;
 
-   case 6:
-      // Linedef -> Flip
-      if (objtype == OBJ_LINEDEFS)
-	 {
-	 FlipLineDefs (*list, 1);
-	 }
-      // Sector -> Distribute ceiling heights
-      else if (objtype == OBJ_SECTORS)
-	 {
-	 if (! (*list)->next || ! (*list)->next->next)
+    case 6:
+	// Linedef -> Flip
+	if (objtype == OBJ_LINEDEFS)
+	{
+	    FlipLineDefs(*list, 1);
+	}
+	// Sector -> Distribute ceiling heights
+	else if (objtype == OBJ_SECTORS)
+	{
+	    if (!(*list)->next || !(*list)->next->next)
 	    {
-	    Beep ();
-	    Notify (-1, -1, "You must select three or more sectors", 0);
+		Beep();
+		Notify(-1, -1, "You must select three or more sectors", 0);
 	    }
-	 else
+	    else
 	    {
-	    DistributeSectorCeilings (*list);
+		DistributeSectorCeilings(*list);
 	    }
-	 }
-      // Things -> Mirror vertically
-      else if (objtype == OBJ_THINGS)
-	 {
-	 flip_mirror (*list, OBJ_THINGS, 'f');
-         }
-      // Vertex -> Mirror horizontally
-      else if (objtype == OBJ_VERTICES)
-	 {
-	 flip_mirror (*list, OBJ_VERTICES, 'm');
-	 }
-      break;
+	}
+	// Things -> Mirror vertically
+	else if (objtype == OBJ_THINGS)
+	{
+	    flip_mirror(*list, OBJ_THINGS, 'f');
+	}
+	// Vertex -> Mirror horizontally
+	else if (objtype == OBJ_VERTICES)
+	{
+	    flip_mirror(*list, OBJ_VERTICES, 'm');
+	}
+	break;
 
-   case 7:
-      // Linedefs -> Swap sidedefs
-      if (objtype == OBJ_LINEDEFS)
-	 {
-	 if (Expert
-            || blindly_swap_sidedefs
-            || Confirm (-1, -1,
-               "Warning: the sector references are also swapped",
-               "You may get strange results if you don't know what you are doing..."))
-	    FlipLineDefs (*list, 0);
-	 }
-      // Sectors -> Raise or lower
-      else if (objtype == OBJ_SECTORS)
-	 {
-	 RaiseOrLowerSectors (*list);
-	 }
-      // Vertices -> Mirror vertically
-      else if (objtype == OBJ_VERTICES)
-	 {
-	 flip_mirror (*list, OBJ_VERTICES, 'f');
-	 }
-      break;
+    case 7:
+	// Linedefs -> Swap sidedefs
+	if (objtype == OBJ_LINEDEFS)
+	{
+	    if (Expert
+		|| blindly_swap_sidedefs
+		|| Confirm(-1, -1,
+			   "Warning: the sector references are also swapped",
+			   "You may get strange results if you don't know what you are doing..."))
+		FlipLineDefs(*list, 0);
+	}
+	// Sectors -> Raise or lower
+	else if (objtype == OBJ_SECTORS)
+	{
+	    RaiseOrLowerSectors(*list);
+	}
+	// Vertices -> Mirror vertically
+	else if (objtype == OBJ_VERTICES)
+	{
+	    flip_mirror(*list, OBJ_VERTICES, 'f');
+	}
+	break;
 
-   case 8:
-      // Linedef ->  Align textures vertically
-      if (objtype == OBJ_LINEDEFS)
-	 {
-	 SelPtr sdlist, cur;
+    case 8:
+	// Linedef ->  Align textures vertically
+	if (objtype == OBJ_LINEDEFS)
+	{
+	    SelPtr sdlist, cur;
 
-	 /* select all sidedefs */
-	 sdlist = 0;
-	 for (cur = *list; cur; cur = cur->next)
+	    /* select all sidedefs */
+	    sdlist = 0;
+	    for (cur = *list; cur; cur = cur->next)
 	    {
-	    if (LineDefs[cur->objnum].sidedef1 >= 0)
-	       SelectObject (&sdlist, LineDefs[cur->objnum].sidedef1);
-	    if (LineDefs[cur->objnum].sidedef2 >= 0)
-	       SelectObject (&sdlist, LineDefs[cur->objnum].sidedef2);
+		if (LineDefs[cur->objnum].sidedef1 >= 0)
+		    SelectObject(&sdlist, LineDefs[cur->objnum].sidedef1);
+		if (LineDefs[cur->objnum].sidedef2 >= 0)
+		    SelectObject(&sdlist, LineDefs[cur->objnum].sidedef2);
 	    }
-	 /* align the textures along the Y axis (height) */
-	 AlignTexturesY (&sdlist);
-	 }
-      // Sector -> Brighten or darken
-      else if (objtype == OBJ_SECTORS)
-	 {
-	 BrightenOrDarkenSectors (*list);
-	 }
-      break;
+	    /* align the textures along the Y axis (height) */
+	    AlignTexturesY(&sdlist);
+	}
+	// Sector -> Brighten or darken
+	else if (objtype == OBJ_SECTORS)
+	{
+	    BrightenOrDarkenSectors(*list);
+	}
+	break;
 
-   case 9:
-      // Linedef -> Align texture horizontally
-      if (objtype == OBJ_LINEDEFS)
-	 {
-	 SelPtr sdlist, cur;
+    case 9:
+	// Linedef -> Align texture horizontally
+	if (objtype == OBJ_LINEDEFS)
+	{
+	    SelPtr sdlist, cur;
 
-	 /* select all sidedefs */
-	 sdlist = 0;
-	 for (cur = *list; cur; cur = cur->next)
+	    /* select all sidedefs */
+	    sdlist = 0;
+	    for (cur = *list; cur; cur = cur->next)
 	    {
-	    if (LineDefs[cur->objnum].sidedef1 >= 0)
-	       SelectObject (&sdlist, LineDefs[cur->objnum].sidedef1);
-	    if (LineDefs[cur->objnum].sidedef2 >= 0)
-	       SelectObject (&sdlist, LineDefs[cur->objnum].sidedef2);
+		if (LineDefs[cur->objnum].sidedef1 >= 0)
+		    SelectObject(&sdlist, LineDefs[cur->objnum].sidedef1);
+		if (LineDefs[cur->objnum].sidedef2 >= 0)
+		    SelectObject(&sdlist, LineDefs[cur->objnum].sidedef2);
 	    }
-	 /* align the textures along the X axis (width) */
-	 AlignTexturesX (&sdlist);
-	 }
-      // Sector -> Unlink room
-      else if (objtype == OBJ_SECTORS)
-	 {
-	 NotImplemented ();  // FIXME
-	 break;
-	 }
-      break;
+	    /* align the textures along the X axis (width) */
+	    AlignTexturesX(&sdlist);
+	}
+	// Sector -> Unlink room
+	else if (objtype == OBJ_SECTORS)
+	{
+	    NotImplemented();	// FIXME
+	    break;
+	}
+	break;
 
-   case 10:
-      // Linedef -> Make linedef single-sided
-      if (objtype == OBJ_LINEDEFS)
-	 {
-	 SelPtr cur;
-	 for (cur = *list; cur; cur = cur->next)
+    case 10:
+	// Linedef -> Make linedef single-sided
+	if (objtype == OBJ_LINEDEFS)
+	{
+	    SelPtr cur;
+	    for (cur = *list; cur; cur = cur->next)
 	    {
-	    struct LineDef *l = LineDefs + cur->objnum;
-	    l->sidedef2 = -1;  /* remove ref. to 2nd SD */
-	    l->flags &= ~0x04; /* clear "2S" bit */
-	    l->flags |= 0x01;  /* set "Im" bit */
+		struct LineDef *l = LineDefs + cur->objnum;
+		l->sidedef2 = -1;	/* remove ref. to 2nd SD */
+		l->flags &= ~0x04;	/* clear "2S" bit */
+		l->flags |= 0x01;	/* set "Im" bit */
 
-	    if (is_sidedef (l->sidedef1))
-	       {
-	       struct SideDef *s = SideDefs + l->sidedef1;
-	       strcpy (s->tex1, "-");
-	       strcpy (s->tex2, "-");
-	       strcpy (s->tex3, default_middle_texture);
-	       }
-	    /* Don't delete the 2nd sidedef, it could be used
-               by another linedef. And if it isn't, the next
-               cross-references check will delete it anyway. */
+		if (is_sidedef(l->sidedef1))
+		{
+		    struct SideDef *s = SideDefs + l->sidedef1;
+		    strcpy(s->tex1, "-");
+		    strcpy(s->tex2, "-");
+		    strcpy(s->tex3, default_middle_texture);
+		}
+		/* Don't delete the 2nd sidedef, it could be used
+		   by another linedef. And if it isn't, the next
+		   cross-references check will delete it anyway. */
 	    }
-	 }
-      // Sector -> Mirror horizontally
-      else if (objtype == OBJ_SECTORS)
-	 {
-	 flip_mirror (*list, OBJ_SECTORS, 'm');
-	 }
-      break;
+	}
+	// Sector -> Mirror horizontally
+	else if (objtype == OBJ_SECTORS)
+	{
+	    flip_mirror(*list, OBJ_SECTORS, 'm');
+	}
+	break;
 
-   case 11:
-      // Linedef -> Make rectangular nook
-      if (objtype == OBJ_LINEDEFS)
-	 MakeRectangularNook (*list, 32, 16, 0);
-      // Sector -> Mirror vertically
-      else if (objtype == OBJ_SECTORS)
-	 {
-	 flip_mirror (*list, OBJ_SECTORS, 'f');
-	 }
-      break;
+    case 11:
+	// Linedef -> Make rectangular nook
+	if (objtype == OBJ_LINEDEFS)
+	    MakeRectangularNook(*list, 32, 16, 0);
+	// Sector -> Mirror vertically
+	else if (objtype == OBJ_SECTORS)
+	{
+	    flip_mirror(*list, OBJ_SECTORS, 'f');
+	}
+	break;
 
-   case 12:
-      // Linedef -> Make rectangular boss
-      if (objtype == OBJ_LINEDEFS)
-	 MakeRectangularNook (*list, 32, 16, 1);
-      // Sector -> Swap flats
-      else if (objtype == OBJ_SECTORS)
-	 swap_flats (*list);
-      break;
+    case 12:
+	// Linedef -> Make rectangular boss
+	if (objtype == OBJ_LINEDEFS)
+	    MakeRectangularNook(*list, 32, 16, 1);
+	// Sector -> Swap flats
+	else if (objtype == OBJ_SECTORS)
+	    swap_flats(*list);
+	break;
 
-   case 13:
-      // Linedef -> Set length (1st vertex)
-      if (objtype == OBJ_LINEDEFS)
-	 {
-	 static int length = 24;
-	 length = InputIntegerValue (-1, -1, -10000, 10000, length);
-	 if (length != IIV_CANCEL)
-	   SetLinedefLength (*list, length, 0);
-	 }
-      break;
+    case 13:
+	// Linedef -> Set length (1st vertex)
+	if (objtype == OBJ_LINEDEFS)
+	{
+	    static int length = 24;
+	    length = InputIntegerValue(-1, -1, -10000, 10000, length);
+	    if (length != IIV_CANCEL)
+		SetLinedefLength(*list, length, 0);
+	}
+	break;
 
-   case 14:
-      // Linedef -> Set length (2nd vertex)
-      if (objtype == OBJ_LINEDEFS)
-	 {
-	 static int length = 24;
-	 length = InputIntegerValue (-1, -1, -10000, 10000, length);
-	 if (length != IIV_CANCEL)
-	   SetLinedefLength (*list, length, 1);
-	 }
-      break;
+    case 14:
+	// Linedef -> Set length (2nd vertex)
+	if (objtype == OBJ_LINEDEFS)
+	{
+	    static int length = 24;
+	    length = InputIntegerValue(-1, -1, -10000, 10000, length);
+	    if (length != IIV_CANCEL)
+		SetLinedefLength(*list, length, 1);
+	}
+	break;
 
-   case 15:
-      // Linedef -> Unlink 1st sidedef
-      if (objtype == OBJ_LINEDEFS)
-         unlink_sidedef (*list, 1, 0);
-      break;
+    case 15:
+	// Linedef -> Unlink 1st sidedef
+	if (objtype == OBJ_LINEDEFS)
+	    unlink_sidedef(*list, 1, 0);
+	break;
 
-   case 16:
-      // Linedef -> Unlink 2nd sidedef
-      if (objtype == OBJ_LINEDEFS)
-         unlink_sidedef (*list, 0, 1);
-      break;
+    case 16:
+	// Linedef -> Unlink 2nd sidedef
+	if (objtype == OBJ_LINEDEFS)
+	    unlink_sidedef(*list, 0, 1);
+	break;
 
-   case 17:
-      // Linedef -> Mirror horizontally
-      flip_mirror (*list, OBJ_LINEDEFS, 'm');
-      break;
-      
-   case 18 :
-      // Linedef -> Mirror vertically
-      flip_mirror (*list, OBJ_LINEDEFS, 'f');
-      break;
+    case 17:
+	// Linedef -> Mirror horizontally
+	flip_mirror(*list, OBJ_LINEDEFS, 'm');
+	break;
 
-   case 19 :
-      // Linedef -> Cut a slice out of a sector
-      if (objtype == OBJ_LINEDEFS)
-	 {
-	 if (! (*list)->next || (*list)->next->next)
+    case 18:
+	// Linedef -> Mirror vertically
+	flip_mirror(*list, OBJ_LINEDEFS, 'f');
+	break;
+
+    case 19:
+	// Linedef -> Cut a slice out of a sector
+	if (objtype == OBJ_LINEDEFS)
+	{
+	    if (!(*list)->next || (*list)->next->next)
 	    {
-	    Beep ();
-	    Notify (-1, -1, "You must select exactly two linedefs", 0);
-	    }
-	 else
-	    {
-	    sector_slice ((*list)->next->objnum, (*list)->objnum);
-	    ForgetSelection (list);
+		Beep();
+		Notify(-1, -1, "You must select exactly two linedefs", 0);
 	    }
-	 }
-      break;
-   }
+	    else
+	    {
+		sector_slice((*list)->next->objnum, (*list)->objnum);
+		ForgetSelection(list);
+	    }
+	}
+	break;
+    }
 }
-
-
-
--- a/src/editobj.h	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/editobj.h	Sat Sep 24 14:16:04 2011 +0300
@@ -4,6 +4,5 @@
  */
 
 
-void DisplayObjectInfo (const edit_t *e, int); /* SWAP! */
-void input_objid (Objid& objid, const Objid& init, int x0, int y0);
-
+void DisplayObjectInfo(const edit_t * e, int);	/* SWAP! */
+void input_objid(Objid & objid, const Objid & init, int x0, int y0);
--- a/src/editsave.cc	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/editsave.cc	Sat Sep 24 14:16:04 2011 +0300
@@ -77,197 +77,197 @@
  */
 
 #ifdef NEW_SAVE_METHOD
-bool save_save_as (bool prompt)
+bool save_save_as(bool prompt)
 {
-  static char l[WAD_NAME + 1];  // "static" to avoid memory shortages
-  static y_file_name_t f;	// "static" to avoid memory shortages
- 
-  if (! CheckStartingPos ())
-    return;
+    static char l[WAD_NAME + 1];	// "static" to avoid memory shortages
+    static y_file_name_t f;	// "static" to avoid memory shortages
+
+    if (!CheckStartingPos())
+	return;
 
-  // Fill in the level name
-  if (*Level_name)
-    al_scps (l, Level_name, sizeof l - 1);
-  else
-  {
-    prompt = true;
-    if (yg_level_name == YGLN_MAP01)
-      strcpy (l, "map01");
+    // Fill in the level name
+    if (*Level_name)
+	al_scps(l, Level_name, sizeof l - 1);
+    else
+    {
+	prompt = true;
+	if (yg_level_name == YGLN_MAP01)
+	    strcpy(l, "map01");
+	else
+	{
+	    strcpy(l, "e1m1");
+	    if (yg_level_name != YGLN_E1M1 && yg_level_name != YGLN_E1M10)
+		nf_bug("Bad yg_level_name %d", (int) yg_level_name);
+	}
+    }
+
+    // Fill in the file name
+    if (*Level_file_name)
+	al_scps(f, file_name, sizeof f - 1);
     else
     {
-      strcpy (l, "e1m1");
-      if (yg_level_name != YGLN_E1M1 && yg_level_name != YGLN_E1M10)
-	nf_bug ("Bad yg_level_name %d", (int) yg_level_name);
+	prompt = true;
+	al_scpslower(f, l, sizeof f - 1);
+	al_saps(f, ".wad", sizeof f - 1);
     }
-  }
+
+    // Create the dialog
+    Entry2 e("Save level as...",
+	     "Level %*S\nFile %+*s\n", sizeof l - 1, l, sizeof f - 1, f);
+
+  try_again:
 
-  // Fill in the file name
-  if (*Level_file_name)
-    al_scps (f, file_name, sizeof f - 1);
-  else
-  {
-    prompt = true;
-    al_scpslower (f, l, sizeof f - 1);
-    al_saps (f, ".wad", sizeof f - 1);
-  }
+    // If necessary, prompt for new level name and file name
+    if (prompt || !fncmp(level_name, MainWad))
+    {
+	int r = e.loop();
+	if (!r)			// Cancelled by user
+	    return false;	// Didn't save
+    }
 
-  // Create the dialog
-  Entry2 e ("Save level as...",
-      "Level %*S\nFile %+*s\n", sizeof l - 1, l, sizeof f - 1, f);
-
-try_again :
-
-  // If necessary, prompt for new level name and file name
-  if (prompt || ! fncmp (level_name, MainWad))
-  {
-    int r = e.loop ();
-    if (! r)  // Cancelled by user
-      return false;  // Didn't save
-  }
+    printf("Saving as \"%s\" into \"%s\"\n", l, f);
+    //if (! ok_to_use_weird_level_name (l))
+    //  goto try_again;
+    //if (! ok_to_overwrite (f))
+    //  goto try_again;
 
-  printf ("Saving as \"%s\" into \"%s\"\n", l, f);
-  //if (! ok_to_use_weird_level_name (l))
-  //  goto try_again;
-  //if (! ok_to_overwrite (f))
-  //  goto try_again;
-
-  // If file already exists, ask for confirmation.
-  if (al_fnature (l) == 1)
-  {
-    bool ok = Confirm (-1, -1, "This file already exists. Saving to it will"
-	" overwrite _everything_",
-	"else it might contain, including other levels or lumps !");
-    if (! ok)
+    // If file already exists, ask for confirmation.
+    if (al_fnature(l) == 1)
     {
-      prompt = true;
-      goto try_again;
+	bool ok =
+	    Confirm(-1, -1,
+		    "This file already exists. Saving to it will"
+		    " overwrite _everything_",
+		    "else it might contain, including other levels or lumps !");
+	if (!ok)
+	{
+	    prompt = true;
+	    goto try_again;
+	}
     }
-  }
 
-  // Try to save
-  int r = SaveLevelData (...);
-  if (r)
-  {
-    Notify (-1, -1, "Could not save to file", strerror (errno));
-    prompt = true;
-    goto try_again;
-  }
+    // Try to save
+    int r = SaveLevelData( ...);
+    if (r)
+    {
+	Notify(-1, -1, "Could not save to file", strerror(errno));
+	prompt = true;
+	goto try_again;
+    }
 
-  // Successfully saved
-  Level = FindMasterDir (levelname);  // FIXME useless ?
-  al_scps (Level_name,            l, sizeof Level_name            - 1);
-  al_scps (Level_file_name,       f, sizeof Level_file_name       - 1);
-  al_scps (Level_file_name_saved, f, sizeof Level_file_name_saved - 1);
-  return true;  // Did save
+    // Successfully saved
+    Level = FindMasterDir(levelname);	// FIXME useless ?
+    al_scps(Level_name, l, sizeof Level_name - 1);
+    al_scps(Level_file_name, f, sizeof Level_file_name - 1);
+    al_scps(Level_file_name_saved, f, sizeof Level_file_name_saved - 1);
+    return true;		// Did save
 }
-#else  /* OLD_SAVE_METHOD */
+#else /* OLD_SAVE_METHOD */
 
 
 /*
    get the name of the new wad file (returns NULL on Esc)
 */
 
-char *GetWadFileName (const char *levelname)
+char *GetWadFileName(const char *levelname)
 {
 #define BUFSZ 79
-  char *outfile = (char *) GetMemory (BUFSZ + 1);
+    char *outfile = (char *) GetMemory(BUFSZ + 1);
 
-  /* get the file name */
-  // If no name, find a default one
-  if (! levelname)
-  {
-    if (yg_level_name == YGLN_E1M1 || yg_level_name == YGLN_E1M10)
-      levelname = "E1M1";
-    else if (yg_level_name == YGLN_MAP01)
-      levelname = "MAP01";
-    else
+    /* get the file name */
+    // If no name, find a default one
+    if (!levelname)
     {
-      nf_bug ("Bad ygd_level_name %d, using E1M1.", (int) yg_level_name);
-      levelname = "E1M1";
+	if (yg_level_name == YGLN_E1M1 || yg_level_name == YGLN_E1M10)
+	    levelname = "E1M1";
+	else if (yg_level_name == YGLN_MAP01)
+	    levelname = "MAP01";
+	else
+	{
+	    nf_bug("Bad ygd_level_name %d, using E1M1.", (int) yg_level_name);
+	    levelname = "E1M1";
+	}
     }
-  }
 
-  if (! Level
-    || ! Level->wadfile
-    || ! fncmp (Level->wadfile->filename, MainWad))
-  {
-    al_scpslower (outfile, levelname, BUFSZ);
-    al_saps (outfile, ".wad", BUFSZ);
-  }
-  else
-    strcpy (outfile, Level->wadfile->filename);
-  do
-    InputFileName (-1, -1, "Name of the new wad file:", BUFSZ, outfile);
-  while (! fncmp (outfile, MainWad));
-  /* escape */
-  if (outfile[0] == '\0')
-  {
-    FreeMemory (outfile);
-    return 0;
-  }
-  /* if the wad file already exists, rename it to "*.bak" */
-  Wad_file *wf;
-  for (wad_list.rewind (); wad_list.get (wf);)
-    if (fncmp (outfile, wf->filename) == 0)
+    if (!Level
+	|| !Level->wadfile || !fncmp(Level->wadfile->filename, MainWad))
+    {
+	al_scpslower(outfile, levelname, BUFSZ);
+	al_saps(outfile, ".wad", BUFSZ);
+    }
+    else
+	strcpy(outfile, Level->wadfile->filename);
+    do
+	InputFileName(-1, -1, "Name of the new wad file:", BUFSZ, outfile);
+    while (!fncmp(outfile, MainWad));
+    /* escape */
+    if (outfile[0] == '\0')
     {
-      verbmsg ("wf->filename: %s\n", wf->filename);	// DEBUG
-      verbmsg ("wf->fp        %p\n", wf->fp);		// DEBUG
-      verbmsg ("outfile       %s\n", outfile);		// DEBUG
-      al_fdrv_t drv;
-      al_fpath_t path;
-      al_fbase_t base;
+	FreeMemory(outfile);
+	return 0;
+    }
+    /* if the wad file already exists, rename it to "*.bak" */
+    Wad_file *wf;
+    for (wad_list.rewind(); wad_list.get(wf);)
+	if (fncmp(outfile, wf->filename) == 0)
+	{
+	    verbmsg("wf->filename: %s\n", wf->filename);	// DEBUG
+	    verbmsg("wf->fp        %p\n", wf->fp);	// DEBUG
+	    verbmsg("outfile       %s\n", outfile);	// DEBUG
+	    al_fdrv_t drv;
+	    al_fpath_t path;
+	    al_fbase_t base;
 
-      al_fana (wf->filename, drv, path, base, 0);
-      sprintf (wf->filename, "%s%s%s.bak", drv, path, base);
-      verbmsg ("setting wf->filename to %s\n", wf->filename);  // DEBUG
-      /* Need to close, then reopen: problems with SHARE.EXE */
-      verbmsg ("closing %p\n", wf->fp);				// DEBUG
-      fclose (wf->fp);
-      verbmsg ("renaming %s -> %s\n", outfile, wf->filename);	// DEBUG
-      if (rename (outfile, wf->filename) != 0)
-      {
-	verbmsg ("removing %s\n", wf->filename);  // DEBUG
-	if (remove (wf->filename) != 0 && errno != ENOENT)
-	{
-	  char buf1[81];
-	  char buf2[81];
-	  y_snprintf (buf1, sizeof buf1, "Could not delete \"%.64s\"",
-	    wf->filename);
-	  y_snprintf (buf2, sizeof buf2, "(%.64s)", strerror (errno));
-	  Notify (-1, -1, buf1, buf2);
-	  return 0;
+	    al_fana(wf->filename, drv, path, base, 0);
+	    sprintf(wf->filename, "%s%s%s.bak", drv, path, base);
+	    verbmsg("setting wf->filename to %s\n", wf->filename);	// DEBUG
+	    /* Need to close, then reopen: problems with SHARE.EXE */
+	    verbmsg("closing %p\n", wf->fp);	// DEBUG
+	    fclose(wf->fp);
+	    verbmsg("renaming %s -> %s\n", outfile, wf->filename);	// DEBUG
+	    if (rename(outfile, wf->filename) != 0)
+	    {
+		verbmsg("removing %s\n", wf->filename);	// DEBUG
+		if (remove(wf->filename) != 0 && errno != ENOENT)
+		{
+		    char buf1[81];
+		    char buf2[81];
+		    y_snprintf(buf1, sizeof buf1,
+			       "Could not delete \"%.64s\"", wf->filename);
+		    y_snprintf(buf2, sizeof buf2, "(%.64s)", strerror(errno));
+		    Notify(-1, -1, buf1, buf2);
+		    return 0;
+		}
+		verbmsg("renaming %s -> %s\n", outfile, wf->filename);	// DEBUG
+		if (rename(outfile, wf->filename))
+		{
+		    char buf1[81];
+		    char buf2[81];
+		    y_snprintf(buf1, sizeof buf1,
+			       "Could not rename \"%.64s\"", outfile);
+		    y_snprintf(buf2, sizeof buf2, "as \"%.64s\" (%.64s)",
+			       wf->filename, strerror(errno));
+		    Notify(-1, -1, buf1, buf2);
+		    return 0;
+		}
+	    }
+	    verbmsg("opening %s\n", wf->filename);	// DEBUG
+	    wf->fp = fopen(wf->filename, "rb");
+	    if (wf->fp == 0)
+	    {
+		char buf1[81];
+		char buf2[81];
+		y_snprintf(buf1, sizeof buf1, "Could not reopen \"%.64s\"",
+			   wf->filename);
+		y_snprintf(buf2, sizeof buf2, "(%.64s)", strerror(errno));
+		Notify(-1, -1, buf1, buf2);
+		return 0;
+	    }
+	    verbmsg("wf->filename: %s\n", wf->filename);	// DEBUG
+	    verbmsg("wf->fp        %p\n", wf->fp);	// DEBUG
+	    verbmsg("outfile       %s\n", outfile);	// DEBUG
+	    break;
 	}
-	verbmsg ("renaming %s -> %s\n", outfile, wf->filename);  // DEBUG
-	if (rename (outfile, wf->filename))
-	{
-	  char buf1[81];
-	  char buf2[81];
-	  y_snprintf (buf1, sizeof buf1, "Could not rename \"%.64s\"",
-	    outfile);
-	  y_snprintf (buf2, sizeof buf2, "as \"%.64s\" (%.64s)",
-	    wf->filename, strerror (errno));
-	  Notify (-1, -1, buf1, buf2);
-	  return 0;
-	}
-      }
-      verbmsg ("opening %s\n", wf->filename); // DEBUG
-      wf->fp = fopen (wf->filename, "rb");
-      if (wf->fp == 0)
-      {
-	char buf1[81];
-	char buf2[81];
-	y_snprintf (buf1, sizeof buf1, "Could not reopen \"%.64s\"",
-	  wf->filename);
-	y_snprintf (buf2, sizeof buf2, "(%.64s)", strerror (errno));
-	Notify (-1, -1, buf1, buf2);
-	return 0;
-      }
-      verbmsg ("wf->filename: %s\n", wf->filename);	// DEBUG
-      verbmsg ("wf->fp        %p\n", wf->fp);		// DEBUG
-      verbmsg ("outfile       %s\n", outfile);		// DEBUG
-      break;
-    }
-  return outfile;
+    return outfile;
 }
 #endif
-
--- a/src/editsave.h	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/editsave.h	Sat Sep 24 14:16:04 2011 +0300
@@ -5,7 +5,6 @@
 
 
 #ifdef NEW_SAVE_METHOD
-bool save_save_as (bool prompt);
+bool save_save_as(bool prompt);
 #endif
-char *GetWadFileName (const char *levelname);
-
+char *GetWadFileName(const char *levelname);
--- a/src/editzoom.cc	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/editzoom.cc	Sat Sep 24 14:16:04 2011 +0300
@@ -39,61 +39,63 @@
 double digit_zoom_factors[10];
 
 
-void edit_zoom_init ()
+void edit_zoom_init()
 {
-  double factor = digit_zoom_base / 100.0;
-  double step   = digit_zoom_step != 0 ? (digit_zoom_step + 100.0) / 100
-				       : pow (2, -.5);
-  for (int i = 1; i <= 10; i++, factor *= step)
-    digit_zoom_factors[i % 10] = factor;
+    double factor = digit_zoom_base / 100.0;
+    double step = digit_zoom_step != 0 ? (digit_zoom_step + 100.0) / 100
+	: pow(2, -.5);
+    for (int i = 1; i <= 10; i++, factor *= step)
+	digit_zoom_factors[i % 10] = factor;
 }
 
 
-int edit_zoom_in (edit_t *e)
+int edit_zoom_in(edit_t * e)
 {
-  if (! e) return 1;  // Prevent compiler warning about unused .p.
-  double step = zoom_step != 0 ? (zoom_step + 100.0) / 100 : sqrt (2);
-  if (Scale * step > 10.0)
-    return 1;
-  OrigX += (int) ((is.x - ScrCenterX) / Scale);
-  OrigY += (int) ((ScrCenterY - is.y) / Scale);
-  Scale *= step;
-  OrigX -= (int) ((is.x - ScrCenterX) / Scale);
-  OrigY -= (int) ((ScrCenterY - is.y) / Scale);
-  send_event (YE_ZOOM_CHANGED);
-  return 0;
+    if (!e)
+	return 1;		// Prevent compiler warning about unused .p.
+    double step = zoom_step != 0 ? (zoom_step + 100.0) / 100 : sqrt(2);
+    if (Scale * step > 10.0)
+	return 1;
+    OrigX += (int) ((is.x - ScrCenterX) / Scale);
+    OrigY += (int) ((ScrCenterY - is.y) / Scale);
+    Scale *= step;
+    OrigX -= (int) ((is.x - ScrCenterX) / Scale);
+    OrigY -= (int) ((ScrCenterY - is.y) / Scale);
+    send_event(YE_ZOOM_CHANGED);
+    return 0;
 }
 
 
-int edit_zoom_out (edit_t *e)
+int edit_zoom_out(edit_t * e)
 {
-  if (! e) return 1;  // Prevent compiler warning about unused .p.
-  double step = zoom_step != 0 ? (zoom_step + 100.0) / 100 : sqrt (2);
-  if (Scale / step < 0.05)
-    return 1;
-  OrigX += (int) ((is.x - ScrCenterX) / Scale);
-  OrigY += (int) ((ScrCenterY - is.y) / Scale);
-  Scale /= step;
-  OrigX -= (int) ((is.x - ScrCenterX) / Scale);
-  OrigY -= (int) ((ScrCenterY - is.y) / Scale);
-  send_event (YE_ZOOM_CHANGED);
-  return 0;
+    if (!e)
+	return 1;		// Prevent compiler warning about unused .p.
+    double step = zoom_step != 0 ? (zoom_step + 100.0) / 100 : sqrt(2);
+    if (Scale / step < 0.05)
+	return 1;
+    OrigX += (int) ((is.x - ScrCenterX) / Scale);
+    OrigY += (int) ((ScrCenterY - is.y) / Scale);
+    Scale /= step;
+    OrigX -= (int) ((is.x - ScrCenterX) / Scale);
+    OrigY -= (int) ((ScrCenterY - is.y) / Scale);
+    send_event(YE_ZOOM_CHANGED);
+    return 0;
 }
 
 
-int edit_set_zoom (edit_t *e, double zoom_factor)
+int edit_set_zoom(edit_t * e, double zoom_factor)
 {
-  if (! e) return 1;  // Prevent compiler warning about unused .p.
-  if (zoom_factor < 0.05)
-    zoom_factor = 0.05;
-  if (zoom_factor > 10.0)
-    zoom_factor = 10.0;
-  OrigX += (int) ((is.x - ScrCenterX) / Scale);
-  OrigY += (int) ((ScrCenterY - is.y) / Scale);
-  Scale = zoom_factor;
-  OrigX -= (int) ((is.x - ScrCenterX) / Scale);
-  OrigY -= (int) ((ScrCenterY - is.y) / Scale);
-  send_event (YE_ZOOM_CHANGED);
-  return 0;
+    if (!e)
+	return 1;		// Prevent compiler warning about unused .p.
+    if (zoom_factor < 0.05)
+	zoom_factor = 0.05;
+    if (zoom_factor > 10.0)
+	zoom_factor = 10.0;
+    OrigX += (int) ((is.x - ScrCenterX) / Scale);
+    OrigY += (int) ((ScrCenterY - is.y) / Scale);
+    Scale = zoom_factor;
+    OrigX -= (int) ((is.x - ScrCenterX) / Scale);
+    OrigY -= (int) ((ScrCenterY - is.y) / Scale);
+    send_event(YE_ZOOM_CHANGED);
+    return 0;
 }
-
--- a/src/editzoom.h	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/editzoom.h	Sat Sep 24 14:16:04 2011 +0300
@@ -12,7 +12,7 @@
 /*
  *      edit_zoom_init - initialise
  */
-void edit_zoom_init (void);
+void edit_zoom_init(void);
 
 
 /*
@@ -23,7 +23,7 @@
  *
  *	Return 0 on success, non-zero on failure.
  */
-int edit_zoom_in (edit_t *e);
+int edit_zoom_in(edit_t * e);
 
 
 /*
@@ -34,7 +34,7 @@
  *
  *	Return 0 on success, non-zero on failure.
  */
-int edit_zoom_out (edit_t *e);
+int edit_zoom_out(edit_t * e);
 
 
 /*
@@ -45,6 +45,4 @@
  *
  *	Return 0 on success, non-zero on failure.
  */
-int edit_set_zoom (edit_t *e, double zoom_factor);
-
-
+int edit_set_zoom(edit_t * e, double zoom_factor);
--- a/src/edwidget.h	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/edwidget.h	Sat Sep 24 14:16:04 2011 +0300
@@ -5,30 +5,29 @@
  */
 
 
-#ifndef YH_EDWIDGET  /* DO NOT INSERT ANYTHING BEFORE THIS LINE */
+#ifndef YH_EDWIDGET		/* DO NOT INSERT ANYTHING BEFORE THIS LINE */
 #define YH_EDWIDGET
 
 
 class edwidget_c
-   {
-   public :
-      void const unset         ();
-      void const draw          ();	// Draw yourself
-      void const undraw        ();	// If you're drawn, undraw yourself
-      int  const can_undraw    ();	// Can you undraw yourself ?
-      int  const need_to_clear ();	// You need to undraw yself but can't ?
-      void const clear         ();	// Forget you're drawn
-      int  const req_width     ();	// Tell me the width you'd like to have
-      int  const req_height    ();	// Tell me the height you'd like 2 have
-      void const set_x0        (int x0);// This is your top left corner
-      void const set_y0        (int y0);
-      void const set_x1        (int x1);// This is your bottom right corner
-      void const set_y1        (int y1);
-      int  const get_x0        ();	// Tell me where's your top left corner
-      int  const get_y0        ();
-      int  const get_x1        ();	// Tell me where's your bottom right c.
-      int  const get_y1        ();
-   };
+{
+    public:void const unset();
+    void const draw();		// Draw yourself
+    void const undraw();	// If you're drawn, undraw yourself
+    int const can_undraw();	// Can you undraw yourself ?
+    int const need_to_clear();	// You need to undraw yself but can't ?
+    void const clear();		// Forget you're drawn
+    int const req_width();	// Tell me the width you'd like to have
+    int const req_height();	// Tell me the height you'd like 2 have
+    void const set_x0(int x0);	// This is your top left corner
+    void const set_y0(int y0);
+    void const set_x1(int x1);	// This is your bottom right corner
+    void const set_y1(int y1);
+    int const get_x0();		// Tell me where's your top left corner
+    int const get_y0();
+    int const get_x1();		// Tell me where's your bottom right c.
+    int const get_y1();
+};
 
 
-#endif  /* DO NOT ADD ANYTHING AFTER THIS LINE */
+#endif /* DO NOT ADD ANYTHING AFTER THIS LINE */
--- a/src/endian.cc	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/endian.cc	Sat Sep 24 14:16:04 2011 +0300
@@ -35,32 +35,31 @@
 /*
  *	Returns 0 for little-endian, 1 for big-endian
  */
-int native_endianness ()
+int native_endianness()
 {
-verbmsg ("CPU endianness: ");
-union
-   {
-   char mem[17];  // 5 is enough in theory
-   u32 n;
-   } u;
-memset (u.mem, '\0', sizeof (u.mem));
-u.n = 0x31323334;
-if (! strcmp (u.mem, "1234"))
-   {
-   verbmsg ("big-endian\n");
-   return 1;
-   }
-else if (! strcmp (u.mem, "4321"))
-   {
-   verbmsg ("little-endian\n");
-   return 0;
-   }
-else
-   {
-   verbmsg ("unknown\n");
-   warn ("weird endianness \"%s\". Report this to the maintainer!\n", u.mem);
-   return 0;
-   }
+    verbmsg("CPU endianness: ");
+    union
+    {
+	char mem[17];		// 5 is enough in theory
+	u32 n;
+    } u;
+    memset(u.mem, '\0', sizeof(u.mem));
+    u.n = 0x31323334;
+    if (!strcmp(u.mem, "1234"))
+    {
+	verbmsg("big-endian\n");
+	return 1;
+    }
+    else if (!strcmp(u.mem, "4321"))
+    {
+	verbmsg("little-endian\n");
+	return 0;
+    }
+    else
+    {
+	verbmsg("unknown\n");
+	warn("weird endianness \"%s\". Report this to the maintainer!\n",
+	     u.mem);
+	return 0;
+    }
 }
-
-
--- a/src/endian.h	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/endian.h	Sat Sep 24 14:16:04 2011 +0300
@@ -5,6 +5,4 @@
  */
 
 
-int native_endianness ();  // Returns 0 for little-endian, 1 for big-endian
-
-
+int native_endianness();	// Returns 0 for little-endian, 1 for big-endian
--- a/src/entry.cc	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/entry.cc	Sat Sep 24 14:16:04 2011 +0300
@@ -33,7 +33,7 @@
 #include "gfx.h"
 
 
-const char *strgetl (const char *& str, long& value);
+const char *strgetl(const char *&str, long &value);
 
 
 /*
@@ -41,227 +41,228 @@
  *
  *	FIXME *valp, minv and maxv should be changed to long.
  */
-int InputInteger (int x0, int y0, int *valp, int minv, int maxv)
+int InputInteger(int x0, int y0, int *valp, int minv, int maxv)
 {
-  int key;
-  int entry_out_x0;
-  int entry_out_y0;
-  int entry_out_x1;
-  int entry_out_y1;
-  int entry_text_x0;
-  int entry_text_y0;
-  int entry_text_x1;
-  int entry_text_y1;
-  const size_t boxlen    = 7;    // Visible width of entry box
-  const size_t bufmaxlen = 50;     // Slack enough
-  char *buf = new char[bufmaxlen + 1];
+    int key;
+    int entry_out_x0;
+    int entry_out_y0;
+    int entry_out_x1;
+    int entry_out_y1;
+    int entry_text_x0;
+    int entry_text_y0;
+    int entry_text_x1;
+    int entry_text_y1;
+    const size_t boxlen = 7;	// Visible width of entry box
+    const size_t bufmaxlen = 50;	// Slack enough
+    char *buf = new char[bufmaxlen + 1];
 
-  entry_out_x0  = x0;
-  entry_text_x0 = entry_out_x0 + HOLLOW_BORDER + NARROW_HSPACING;
-  entry_text_x1 = entry_text_x0 + boxlen * FONTW - 1;
-  entry_out_x1  = entry_text_x1 + HOLLOW_BORDER + NARROW_HSPACING;
-  entry_out_y0  = y0;
-  entry_text_y0 = entry_out_y0 + HOLLOW_BORDER + NARROW_VSPACING;
-  entry_text_y1 = entry_text_y0 + FONTH - 1;
-  entry_out_y1  = entry_text_y1 + HOLLOW_BORDER + NARROW_VSPACING;
-  DrawScreenBoxHollow (entry_out_x0, entry_out_y0, entry_out_x1, entry_out_y1,
-    BLACK);
-  long val = *valp;
-  sprintf (buf, "%d", *valp);    // FIXME what if we were in hex ?
-  for (bool firstkey = true; ; firstkey = false)
-  {
-    bool ok;
-    {
-      const char *checkp = buf;
-      ok = strgetl (checkp, val) == 0
-        && checkp == buf + strlen (buf)
-	&& val >= minv && val <= maxv;
-    }
-    set_colour (BLACK);
-    DrawScreenBox (entry_text_x0, entry_text_y0, entry_text_x1, entry_text_y1);
-    if (ok)
-      set_colour (WHITE);
-    else
-      set_colour (LIGHTRED);
-    if (strlen (buf) > boxlen)
+    entry_out_x0 = x0;
+    entry_text_x0 = entry_out_x0 + HOLLOW_BORDER + NARROW_HSPACING;
+    entry_text_x1 = entry_text_x0 + boxlen * FONTW - 1;
+    entry_out_x1 = entry_text_x1 + HOLLOW_BORDER + NARROW_HSPACING;
+    entry_out_y0 = y0;
+    entry_text_y0 = entry_out_y0 + HOLLOW_BORDER + NARROW_VSPACING;
+    entry_text_y1 = entry_text_y0 + FONTH - 1;
+    entry_out_y1 = entry_text_y1 + HOLLOW_BORDER + NARROW_VSPACING;
+    DrawScreenBoxHollow(entry_out_x0, entry_out_y0, entry_out_x1,
+			entry_out_y1, BLACK);
+    long val = *valp;
+    sprintf(buf, "%d", *valp);	// FIXME what if we were in hex ?
+    for (bool firstkey = true;; firstkey = false)
     {
-      DrawScreenText (entry_text_x0, entry_text_y0, "<%s",
-	buf + (strlen (buf) - boxlen + 1));
-    }
-    else
-      DrawScreenString (entry_text_x0, entry_text_y0, buf);
+	bool ok;
+	{
+	    const char *checkp = buf;
+	    ok = strgetl(checkp, val) == 0
+		&& checkp == buf + strlen(buf) && val >= minv && val <= maxv;
+	}
+	set_colour(BLACK);
+	DrawScreenBox(entry_text_x0, entry_text_y0, entry_text_x1,
+		      entry_text_y1);
+	if (ok)
+	    set_colour(WHITE);
+	else
+	    set_colour(LIGHTRED);
+	if (strlen(buf) > boxlen)
+	{
+	    DrawScreenText(entry_text_x0, entry_text_y0, "<%s",
+			   buf + (strlen(buf) - boxlen + 1));
+	}
+	else
+	    DrawScreenString(entry_text_x0, entry_text_y0, buf);
 
-    key = get_key ();
-    if (key == YK_BACKSPACE && strlen (buf) > 0)
-    {
-      buf[strlen (buf) - 1] = '\0';
-    }
-    else if (key == YK_RETURN && ok)
-    {
-      *valp = (int) val;
-      break;    // Return current value
-    }
-    else if (key == YK_LEFT || key == YK_RIGHT
-	  || key == YK_UP   || key == YK_DOWN
-	  || key == YK_TAB  || key == YK_BACKTAB)
-    {
-      *valp = (int) val;
-      break;    // Return current value, even if not valid
+	key = get_key();
+	if (key == YK_BACKSPACE && strlen(buf) > 0)
+	{
+	    buf[strlen(buf) - 1] = '\0';
+	}
+	else if (key == YK_RETURN && ok)
+	{
+	    *valp = (int) val;
+	    break;		// Return current value
+	}
+	else if (key == YK_LEFT || key == YK_RIGHT
+		 || key == YK_UP || key == YK_DOWN
+		 || key == YK_TAB || key == YK_BACKTAB)
+	{
+	    *valp = (int) val;
+	    break;		// Return current value, even if not valid
+	}
+	else if (key == YK_ESC)
+	{
+	    *valp = IIV_CANCEL;	// Return an out of range value
+	    break;
+	}
+	else if (is_ordinary(key) && strlen(buf) < bufmaxlen)
+	{
+	    if (firstkey)
+		if (key == ' ')	// Kludge : hit space to append to initial value
+		    continue;
+		else
+		    *buf = '\0';
+	    al_sapc(buf, key, bufmaxlen);
+	}
+	else
+	{
+	    Beep();
+	}
     }
-    else if (key == YK_ESC)
-    {
-      *valp = IIV_CANCEL;    // Return an out of range value
-      break;
-    }
-    else if (is_ordinary (key) && strlen (buf) < bufmaxlen)
-    {
-      if (firstkey)
-	if (key == ' ')    // Kludge : hit space to append to initial value
-	  continue;
-	else
-	  *buf = '\0';
-      al_sapc (buf, key, bufmaxlen);
-    }
-    else
-    {
-      Beep ();
-    }
-  }
 
-  is.key = 0;    // Shouldn't have to do that but EditorLoop() is broken
-  delete[] buf;
-  return key;
+    is.key = 0;			// Shouldn't have to do that but EditorLoop() is broken
+    delete[]buf;
+    return key;
 }
 
 
 /*
    ask for an integer value and check for minimum and maximum
 */
-int InputIntegerValue (int x0, int y0, int minv, int maxv, int defv)
+int InputIntegerValue(int x0, int y0, int minv, int maxv, int defv)
 {
-  int  val, key;
-  char prompt[80];
+    int val, key;
+    char prompt[80];
 
-  y_snprintf (prompt, sizeof prompt,
-    "Enter a number between %d and %d:",
-    minv, maxv);
-  if (x0 < 0)
-    x0 = (ScrMaxX - 25 - FONTW * strlen (prompt)) / 2;
-  if (y0 < 0)
-    y0 = (ScrMaxY - 55) / 2;
-  DrawScreenBox3D (x0, y0, x0 + 25 + FONTW * strlen (prompt), y0 + 55);
-  set_colour (WHITE);
-  DrawScreenText (x0 + 10, y0 + 8, prompt);
-  val = defv;
-  while ((key = InputInteger (x0 + 10, y0 + 28, &val, minv, maxv)) != YK_RETURN
-   && key != YK_ESC)
-    Beep ();
-  return val;
+    y_snprintf(prompt, sizeof prompt,
+	       "Enter a number between %d and %d:", minv, maxv);
+    if (x0 < 0)
+	x0 = (ScrMaxX - 25 - FONTW * strlen(prompt)) / 2;
+    if (y0 < 0)
+	y0 = (ScrMaxY - 55) / 2;
+    DrawScreenBox3D(x0, y0, x0 + 25 + FONTW * strlen(prompt), y0 + 55);
+    set_colour(WHITE);
+    DrawScreenText(x0 + 10, y0 + 8, prompt);
+    val = defv;
+    while ((key =
+	    InputInteger(x0 + 10, y0 + 28, &val, minv, maxv)) != YK_RETURN
+	   && key != YK_ESC)
+	Beep();
+    return val;
 }
 
 
 /*
    ask for a filename
 */
-void InputFileName (int x0, int y0, const char *prompt, size_t maxlen,
-   char *filename)
+void InputFileName(int x0, int y0, const char *prompt, size_t maxlen,
+		   char *filename)
 {
-  int   key;
-  size_t l;
-  size_t boxlen;
-  bool  firstkey;
-  int width;
-  int title_y0;
-  int entry_out_x0;
-  int entry_out_y0;
-  int entry_out_x1;
-  int entry_out_y1;
-  int entry_text_x0;
-  int entry_text_y0;
-  int entry_text_x1;
-  int entry_text_y1;
+    int key;
+    size_t l;
+    size_t boxlen;
+    bool firstkey;
+    int width;
+    int title_y0;
+    int entry_out_x0;
+    int entry_out_y0;
+    int entry_out_x1;
+    int entry_out_y1;
+    int entry_text_x0;
+    int entry_text_y0;
+    int entry_text_x1;
+    int entry_text_y1;
 
-  for (l = strlen (filename) + 1; l <= maxlen; l++)
-    filename [l] = '\0';
-  /* compute the width of the input box */
-  if (maxlen > 20)
-    boxlen = 20;
-  else
-    boxlen = maxlen;
-  /* compute the width of the dialog box */
-  if (strlen (prompt) > boxlen)
-    l = strlen (prompt);
-  else
-    l = boxlen;
+    for (l = strlen(filename) + 1; l <= maxlen; l++)
+	filename[l] = '\0';
+    /* compute the width of the input box */
+    if (maxlen > 20)
+	boxlen = 20;
+    else
+	boxlen = maxlen;
+    /* compute the width of the dialog box */
+    if (strlen(prompt) > boxlen)
+	l = strlen(prompt);
+    else
+	l = boxlen;
 
-  width = 2 * HOLLOW_BORDER + 2 * NARROW_HSPACING + boxlen * FONTW;
-  if ((int) (strlen (prompt) * FONTW) > width)
-    width = strlen (prompt) * FONTW;
-  width += 2 * BOX_BORDER + 2 * WIDE_HSPACING;
+    width = 2 * HOLLOW_BORDER + 2 * NARROW_HSPACING + boxlen * FONTW;
+    if ((int) (strlen(prompt) * FONTW) > width)
+	width = strlen(prompt) * FONTW;
+    width += 2 * BOX_BORDER + 2 * WIDE_HSPACING;
 
-  if (x0 < 0)
-    x0 = (ScrMaxX - width) / 2;
-  if (y0 < 0)
-    y0 = (ScrMaxY - 2 * BOX_BORDER
-		  - 2 * WIDE_VSPACING
-		  - (int) (2.5 * FONTH)
-		  - 2 * HOLLOW_BORDER
-		  - 2 * NARROW_VSPACING) / 2;
-  /* draw the dialog box */
-  entry_out_x0  = x0 + BOX_BORDER + WIDE_HSPACING;
-  entry_text_x0 = entry_out_x0  + HOLLOW_BORDER + NARROW_HSPACING;
-  entry_text_x1 = entry_text_x0 + boxlen * FONTW - 1;
-  entry_out_x1  = entry_text_x1 + NARROW_HSPACING + HOLLOW_BORDER;
-  title_y0      = y0 + BOX_BORDER + WIDE_VSPACING;
-  entry_out_y0  = title_y0 + (int) (1.5 * FONTH);
-  entry_text_y0 = entry_out_y0  + HOLLOW_BORDER + NARROW_VSPACING;
-  entry_text_y1 = entry_text_y0 + FONTH - 1;
-  entry_out_y1  = entry_text_y1 + NARROW_VSPACING + HOLLOW_BORDER;
+    if (x0 < 0)
+	x0 = (ScrMaxX - width) / 2;
+    if (y0 < 0)
+	y0 = (ScrMaxY - 2 * BOX_BORDER
+	      - 2 * WIDE_VSPACING
+	      - (int) (2.5 * FONTH)
+	      - 2 * HOLLOW_BORDER - 2 * NARROW_VSPACING) / 2;
+    /* draw the dialog box */
+    entry_out_x0 = x0 + BOX_BORDER + WIDE_HSPACING;
+    entry_text_x0 = entry_out_x0 + HOLLOW_BORDER + NARROW_HSPACING;
+    entry_text_x1 = entry_text_x0 + boxlen * FONTW - 1;
+    entry_out_x1 = entry_text_x1 + NARROW_HSPACING + HOLLOW_BORDER;
+    title_y0 = y0 + BOX_BORDER + WIDE_VSPACING;
+    entry_out_y0 = title_y0 + (int) (1.5 * FONTH);
+    entry_text_y0 = entry_out_y0 + HOLLOW_BORDER + NARROW_VSPACING;
+    entry_text_y1 = entry_text_y0 + FONTH - 1;
+    entry_out_y1 = entry_text_y1 + NARROW_VSPACING + HOLLOW_BORDER;
 
-  DrawScreenBox3D (x0, y0, x0 + width - 1, entry_out_y1 + WIDE_VSPACING);
-  DrawScreenBoxHollow (entry_out_x0, entry_out_y0, entry_out_x1, entry_out_y1, BLACK);
-  set_colour (WINTITLE);
-  DrawScreenString (entry_out_x0, title_y0, prompt);
-  firstkey = true;
-  for (;;)
-  {
-    l = strlen (filename);
-    set_colour (BLACK);
-    DrawScreenBox (entry_text_x0, entry_text_y0, entry_text_x1, entry_text_y1);
-    set_colour (WHITE);
-    if (l > boxlen)
+    DrawScreenBox3D(x0, y0, x0 + width - 1, entry_out_y1 + WIDE_VSPACING);
+    DrawScreenBoxHollow(entry_out_x0, entry_out_y0, entry_out_x1,
+			entry_out_y1, BLACK);
+    set_colour(WINTITLE);
+    DrawScreenString(entry_out_x0, title_y0, prompt);
+    firstkey = true;
+    for (;;)
     {
-      DrawScreenText (entry_text_x0, entry_text_y0, "<%s",
-	filename + (l - boxlen + 1));
-    }
-    else
-      DrawScreenString (entry_text_x0, entry_text_y0, filename);
-    key = get_key ();
-    if (firstkey && is_ordinary (key))
-    {
-      for (l = 0; l <= maxlen; l++)
-	filename[l] = '\0';
-      l = 0;
+	l = strlen(filename);
+	set_colour(BLACK);
+	DrawScreenBox(entry_text_x0, entry_text_y0, entry_text_x1,
+		      entry_text_y1);
+	set_colour(WHITE);
+	if (l > boxlen)
+	{
+	    DrawScreenText(entry_text_x0, entry_text_y0, "<%s",
+			   filename + (l - boxlen + 1));
+	}
+	else
+	    DrawScreenString(entry_text_x0, entry_text_y0, filename);
+	key = get_key();
+	if (firstkey && is_ordinary(key))
+	{
+	    for (l = 0; l <= maxlen; l++)
+		filename[l] = '\0';
+	    l = 0;
+	}
+	firstkey = false;
+	if (l < maxlen && is_ordinary(key))
+	{
+	    filename[l] = key;
+	    filename[l + 1] = '\0';
+	}
+	else if (l > 0 && key == YK_BACKSPACE)
+	    filename[l - 1] = '\0';
+	else if (key == YK_RETURN)
+	    break;		/* return "filename" */
+	else if (key == YK_ESC)
+	{
+	    filename[0] = '\0';	/* return an empty string */
+	    break;
+	}
+	else
+	    Beep();
     }
-    firstkey = false;
-    if (l < maxlen && is_ordinary (key))
-    {
-      filename[l] = key;
-      filename[l + 1] = '\0';
-    }
-    else if (l > 0 && key == YK_BACKSPACE)
-      filename[l-1] = '\0';
-    else if (key == YK_RETURN)
-      break;  /* return "filename" */
-    else if (key == YK_ESC)
-    {
-      filename[0] = '\0'; /* return an empty string */
-      break;
-    }
-    else
-      Beep ();
-  }
-  is.key = 0;  // Shouldn't have to do that but EditorLoop() is broken
+    is.key = 0;			// Shouldn't have to do that but EditorLoop() is broken
 }
 
 
@@ -277,48 +278,47 @@
  *	<value> is undefined and the return value is a static
  *	string describing the error.
  */
-const char *strgetl (const char *& str, long& value)
+const char *strgetl(const char *&str, long &value)
 {
-  int base = 10;
-  int sign = 1;
+    int base = 10;
+    int sign = 1;
 
-  // Leading + or -
-  if (*str == '-')
-  {
-    sign = -1;
-    str++;
-  }
-  else if (*str == '+')
-    str++;
-
-  // 0- or 0x- prefix
-  if (*str == '0' && (str[1] == 'x' || str[1] == 'X'))
-  {
-    base = 16;
-    str += 2;
-  }
-  else if (*str == '0')
-    base = 8;    // Don't advance str, so that "0" passes the next test
+    // Leading + or -
+    if (*str == '-')
+    {
+	sign = -1;
+	str++;
+    }
+    else if (*str == '+')
+	str++;
 
-  // Check that there is at least one digit
-  if (hextoi (*str) < 0 || hextoi (*str) >= base)
-  {
-    if (base == 8)
-      return "expected an octal digit";
-    else if (base == 10)
-      return "expected a decimal digit";
-    else
-      return "expected a hex digit";
-  }
+    // 0- or 0x- prefix
+    if (*str == '0' && (str[1] == 'x' || str[1] == 'X'))
+    {
+	base = 16;
+	str += 2;
+    }
+    else if (*str == '0')
+	base = 8;		// Don't advance str, so that "0" passes the next test
 
-  // Swallow all non-prefix digits
-  for (value = 0; *str != '\0'; str++)
-  {
-    int digitval = hextoi (*str);
-    if (digitval < 0 || digitval >= base)
-      return 0;
-    value = base * value + sign * digitval;
-  }
-  return 0;
+    // Check that there is at least one digit
+    if (hextoi(*str) < 0 || hextoi(*str) >= base)
+    {
+	if (base == 8)
+	    return "expected an octal digit";
+	else if (base == 10)
+	    return "expected a decimal digit";
+	else
+	    return "expected a hex digit";
+    }
+
+    // Swallow all non-prefix digits
+    for (value = 0; *str != '\0'; str++)
+    {
+	int digitval = hextoi(*str);
+	if (digitval < 0 || digitval >= base)
+	    return 0;
+	value = base * value + sign * digitval;
+    }
+    return 0;
 }
-
--- a/src/entry.h	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/entry.h	Sat Sep 24 14:16:04 2011 +0300
@@ -5,8 +5,6 @@
  */
 
 
-int InputInteger (int, int, int *, int, int);
-int InputIntegerValue (int, int, int, int, int);
-void InputFileName (int, int, const char *, size_t, char *);
-
-
+int InputInteger(int, int, int *, int, int);
+int InputIntegerValue(int, int, int, int, int);
+void InputFileName(int, int, const char *, size_t, char *);
--- a/src/entry2.cc	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/entry2.cc	Sat Sep 24 14:16:04 2011 +0300
@@ -36,252 +36,252 @@
 /*
  *	ctor
  */
-Entry2::Entry2 (const char *title, const char *fmt, ...)
+Entry2::Entry2(const char *title, const char *fmt, ...)
 {
-  this->title = title ? title : "(null)";
-  nfields = count_widgets (fmt);
-  box_len     = new unsigned short[nfields];
-  buf         = new char *[nfields];
-  buf_max_len = new unsigned short[nfields];
-  caption     = new const char *[nfields];
-  entry_drawn = new bool[nfields];
-  entry_flags = new _field_flags_t[nfields];
+    this->title = title ? title : "(null)";
+    nfields = count_widgets(fmt);
+    box_len = new unsigned short[nfields];
+    buf = new char *[nfields];
+    buf_max_len = new unsigned short[nfields];
+    caption = new const char *[nfields];
+    entry_drawn = new bool[nfields];
+    entry_flags = new _field_flags_t[nfields];
 
-  {
-    va_list args;
-    va_start (args, fmt);
-    fill_in_widgets_info (fmt, args);
-  }
+    {
+	va_list args;
+	va_start(args, fmt);
+	fill_in_widgets_info(fmt, args);
+    }
 
-  background_drawn = false;
-  for (size_t f = 0; f < nfields; f++)
-    entry_drawn[f] = false;
-  field_no = 0;  // This seem redundant with jump_to_field (0)
-  		 // but it's not. jump_to_field() really needs
-		 // field_no to be initialized.
-  jump_to_field (0);
-  geom_up_to_date = false;
-  win_x0 = -1;
-  win_y0 = -1;
+    background_drawn = false;
+    for (size_t f = 0; f < nfields; f++)
+	entry_drawn[f] = false;
+    field_no = 0;		// This seem redundant with jump_to_field (0)
+    // but it's not. jump_to_field() really needs
+    // field_no to be initialized.
+    jump_to_field(0);
+    geom_up_to_date = false;
+    win_x0 = -1;
+    win_y0 = -1;
 
-  // Geometry constants
-  entry_hofs     = HOLLOW_BORDER + NARROW_HSPACING;
-  entry_vofs     = HOLLOW_BORDER + NARROW_VSPACING;
-  win_hofs       = BOX_BORDER + WIDE_HSPACING;
-  win_vofs       = BOX_BORDER + WIDE_VSPACING;
-  title_vspacing = FONTH;
+    // Geometry constants
+    entry_hofs = HOLLOW_BORDER + NARROW_HSPACING;
+    entry_vofs = HOLLOW_BORDER + NARROW_VSPACING;
+    win_hofs = BOX_BORDER + WIDE_HSPACING;
+    win_vofs = BOX_BORDER + WIDE_VSPACING;
+    title_vspacing = FONTH;
 }
 
 
 /*
  *	dtor
  */
-Entry2::~Entry2 ()
+Entry2::~Entry2()
 {
-  if (buf)
-    delete[] buf;
-  if (buf_max_len)
-    delete[] buf_max_len;
-  if (box_len)
-    delete[] box_len;
-  if (entry_drawn)
-    delete[] entry_drawn;
-  if (entry_flags)
-    delete[] entry_flags;
-  if (caption)
-    delete[] caption;
+    if (buf)
+	delete[]buf;
+    if (buf_max_len)
+	delete[]buf_max_len;
+    if (box_len)
+	delete[]box_len;
+    if (entry_drawn)
+	delete[]entry_drawn;
+    if (entry_flags)
+	delete[]entry_flags;
+    if (caption)
+	delete[]caption;
 }
 
- 
+
 /*
  *	loop
  *	Block until the user closes the window.
  *	Return 0 on cancel, non-zero on valid.
  */
-int Entry2::loop ()
+int Entry2::loop()
 {
-  int r;
-  for (;;)
-  {
-    get_input_status ();
-    r = process_event (is);
-    refresh ();
-    if (r != ACT_NONE)
-      break;
-  }
-  is.key = 0;  // FIXME Shouldn't have to do that but EditorLoop() is broken
-  if (r == ACT_VALID)
-    return 1;
-  else if (r == ACT_CANCEL)
-    return 0;
-  else
-  {
-    printf ("Internal error: Entry2::process_event returned %d\n", (int) r);
-    return 0;
-  }
+    int r;
+    for (;;)
+    {
+	get_input_status();
+	r = process_event(is);
+	refresh();
+	if (r != ACT_NONE)
+	    break;
+    }
+    is.key = 0;			// FIXME Shouldn't have to do that but EditorLoop() is broken
+    if (r == ACT_VALID)
+	return 1;
+    else if (r == ACT_CANCEL)
+	return 0;
+    else
+    {
+	printf("Internal error: Entry2::process_event returned %d\n",
+	       (int) r);
+	return 0;
+    }
 }
 
 
 /*
  *	process_event
  */
-Entry2_action_t Entry2::process_event (const input_status_t &is)
+Entry2_action_t Entry2::process_event(const input_status_t & is)
 {
-  if (is.key == YE_EXPOSE)
-  {
-    background_drawn = false;
-    return ACT_NONE;
-  }
+    if (is.key == YE_EXPOSE)
+    {
+	background_drawn = false;
+	return ACT_NONE;
+    }
 
-  char *s = buf[field_no];
-  bool redraw = false;
-  size_t max_len = buf_max_len[field_no];
-  size_t l = strlen (s);
-  int key = is.key;
-  _field_flags_t flags = entry_flags[field_no];
+    char *s = buf[field_no];
+    bool redraw = false;
+    size_t max_len = buf_max_len[field_no];
+    size_t l = strlen(s);
+    int key = is.key;
+    _field_flags_t flags = entry_flags[field_no];
+
+    if (first_key && is_ordinary(key))
+    {
+	*s = '\0';
+	l = 0;
+	redraw = true;
+    }
+    first_key = 0;
 
-  if (first_key && is_ordinary (key))
-  {
-    *s = '\0';
-    l = 0;
-    redraw = true;
-  }
-  first_key = 0;
-
-  // Printable character
-  if (is_ordinary (key))
-  {
-    if (l >= max_len)
-      goto reject_key;
-    if (is_integer_entry (flags))
+    // Printable character
+    if (is_ordinary(key))
     {
-      if (l == 1 && s[0] == '0')
-      {
-	if (key == 'x' || key == 'X')
-	  ;
-	else if (! isdigit (key))
-	  goto reject_key;
-        else if (key == '0')
-	  goto reject_key;
+	if (l >= max_len)
+	    goto reject_key;
+	if (is_integer_entry(flags))
+	{
+	    if (l == 1 && s[0] == '0')
+	    {
+		if (key == 'x' || key == 'X')
+		    ;
+		else if (!isdigit(key))
+		    goto reject_key;
+		else if (key == '0')
+		    goto reject_key;
+		else
+		    l = 0;
+	    }
+	    else if (!isdigit(key))
+		goto reject_key;
+	}
+	if (is_string_entry(flags) && (flags & FF_UPPERCASE))
+	    key = toupper(key);
+	s[l] = key;
+	s[l + 1] = '\0';
+	redraw = true;
+    }
+    // [BS]: Backspace
+    else if (key == YK_BACKSPACE)
+    {
+	if (is_integer_entry(flags) && l == 1)
+	    strcpy(s, "0");
+	else if (l > 0)
+	    s[l - 1] = '\0';
 	else
-	  l = 0;
-      }
-      else if (! isdigit (key))
-	goto reject_key;
+	    goto reject_key;
+	redraw = true;
+    }
+    // ^A, [Home]: Go to SOL (Emacs/readline, Doskey)
+    else if (key == YK_HOME || key == 1)
+    {
+	;
+    }
+    // ^B, [Left]: Go to previous character (Emacs, readline)
+    else if (key == YK_LEFT || key == 2)
+    {
+	;
     }
-    if (is_string_entry (flags) && (flags & FF_UPPERCASE))
-      key = toupper (key);
-    s[l] = key;
-    s[l + 1] = '\0';
-    redraw = true;
-  }
-  // [BS]: Backspace
-  else if (key == YK_BACKSPACE)
-  {
-    if (is_integer_entry (flags) && l == 1)
-      strcpy (s, "0");
-    else if (l > 0)
-      s[l-1] = '\0';
-    else
-      goto reject_key;
-    redraw = true;
-  }
-  // ^A, [Home]: Go to SOL (Emacs/readline, Doskey)
-  else if (key == YK_HOME || key == 1)
-  {
-    ;
-  }
-  // ^B, [Left]: Go to previous character (Emacs, readline)
-  else if (key == YK_LEFT || key == 2)
-  {
-    ;
-  }
-  // ^D, [Del]: Delete current character (Emacs, readline)
-  else if (key == YK_DEL || key == 4)
-  {
-    ;
-  }
-  // ^E, [End]: Go to EOL (Emacs/readline, Doskey)
-  else if (key == YK_END || key == 5)
-  {
-    ;
-  }
-  // ^F, [Right]: Go to next character (Emacs/readline)
-  else if (key == YK_RIGHT || key == 6)
-  {
-    ;
-  }
-  // ^K, [Ctrl][End]: Del to EOL (Emacs/readline, Doskey)
-  else if (key == YK_END + YK_CTRL || key == 11)
-  {
-    ;
-  }
-  // ^U, [Ctrl][Home]: Del to SOL (readline, Doskey)
-  else if (key == YK_HOME + YK_CTRL || key == 21)
-  {
-    if ((flags & FF_SUBTYPE) == FF_INTEGER)
-      strcpy (s, "0");
-    else
-      *s = '\0';
-    redraw = true;
-  }
-  // ^W: Del last word (Unix, readline)
-  else if (key == 23)
-  {
-    while (l > 0 && isspace (s[l - 1]))
-      l--;
-    while (l > 0 && ! isspace (s[l - 1]))
-      l--;
-    if (is_integer_entry (flags) && l == 0)
-      strcpy (s, "0");
-    else
-      s[l] = '\0';
-    redraw = true;
-  }
-  // ^X: Decrement (Vim)
-  else if (key == 24)
-  {
-    if (! is_integer_entry (flags))
-      goto reject_key;
-    //v--;
-    //sprintf (s, "%", v);
-  }
-  // [Tab]: Next field
-  else if (key == YK_TAB)
-    next_field ();
-  // [Shift][Tab]: Previous field
-  else if (key == YK_BACKTAB)
-    prev_field ();
-  // [Return]: Validate
-  else if (key == YK_RETURN)
-  {
-    size_t f;
-    for (f = 0; f < nfields; f++)  // No FF_NONEMPTY fields must be empty
-      if (   (entry_flags[f] & FF_TYPE) == FF_ENTRY
-	  && (entry_flags[f] & FF_SUBTYPE) == FF_STRING
-	  && (entry_flags[f] & FF_NONEMPTY)
-	  && buf[f][0] == '\0')
-	break;
-    if (f == nfields)
-      return ACT_VALID;
+    // ^D, [Del]: Delete current character (Emacs, readline)
+    else if (key == YK_DEL || key == 4)
+    {
+	;
+    }
+    // ^E, [End]: Go to EOL (Emacs/readline, Doskey)
+    else if (key == YK_END || key == 5)
+    {
+	;
+    }
+    // ^F, [Right]: Go to next character (Emacs/readline)
+    else if (key == YK_RIGHT || key == 6)
+    {
+	;
+    }
+    // ^K, [Ctrl][End]: Del to EOL (Emacs/readline, Doskey)
+    else if (key == YK_END + YK_CTRL || key == 11)
+    {
+	;
+    }
+    // ^U, [Ctrl][Home]: Del to SOL (readline, Doskey)
+    else if (key == YK_HOME + YK_CTRL || key == 21)
+    {
+	if ((flags & FF_SUBTYPE) == FF_INTEGER)
+	    strcpy(s, "0");
+	else
+	    *s = '\0';
+	redraw = true;
+    }
+    // ^W: Del last word (Unix, readline)
+    else if (key == 23)
+    {
+	while (l > 0 && isspace(s[l - 1]))
+	    l--;
+	while (l > 0 && !isspace(s[l - 1]))
+	    l--;
+	if (is_integer_entry(flags) && l == 0)
+	    strcpy(s, "0");
+	else
+	    s[l] = '\0';
+	redraw = true;
+    }
+    // ^X: Decrement (Vim)
+    else if (key == 24)
+    {
+	if (!is_integer_entry(flags))
+	    goto reject_key;
+	//v--;
+	//sprintf (s, "%", v);
+    }
+    // [Tab]: Next field
+    else if (key == YK_TAB)
+	next_field();
+    // [Shift][Tab]: Previous field
+    else if (key == YK_BACKTAB)
+	prev_field();
+    // [Return]: Validate
+    else if (key == YK_RETURN)
+    {
+	size_t f;
+	for (f = 0; f < nfields; f++)	// No FF_NONEMPTY fields must be empty
+	    if ((entry_flags[f] & FF_TYPE) == FF_ENTRY
+		&& (entry_flags[f] & FF_SUBTYPE) == FF_STRING
+		&& (entry_flags[f] & FF_NONEMPTY) && buf[f][0] == '\0')
+		break;
+	if (f == nfields)
+	    return ACT_VALID;
+	else
+	{
+	    jump_to_field(f);
+	    Beep();
+	}
+    }
+    // [Esc]: Cancel
+    else if (key == YK_ESC)
+	return ACT_CANCEL;
     else
     {
-      jump_to_field (f);
-      Beep ();
+      reject_key:
+	Beep();
     }
-  }
-  // [Esc]: Cancel
-  else if (key == YK_ESC)
-    return ACT_CANCEL;
-  else
-  {
-reject_key :
-    Beep ();
-  }
 
-  if (redraw)
-    entry_drawn[field_no] = false;
-  return ACT_NONE;
+    if (redraw)
+	entry_drawn[field_no] = false;
+    return ACT_NONE;
 }
 
 
@@ -289,73 +289,73 @@
  *	refresh
  *	Update the display
  */
-void Entry2::refresh ()
+void Entry2::refresh()
 {
-  /* Draw the background (the part that never
-     changes unless the window is obscured). */
-  if (! background_drawn)
-  {
-    if (! geom_up_to_date)
-      do_geom ();
+    /* Draw the background (the part that never
+       changes unless the window is obscured). */
+    if (!background_drawn)
+    {
+	if (!geom_up_to_date)
+	    do_geom();
 
-    DrawScreenBox3D (win_x0, win_y0, win_x1, win_y1);
-    push_colour (WINTITLE);
-    DrawScreenString (title_x0, title_y0, title);
-    set_colour (WINFG);
+	DrawScreenBox3D(win_x0, win_y0, win_x1, win_y1);
+	push_colour(WINTITLE);
+	DrawScreenString(title_x0, title_y0, title);
+	set_colour(WINFG);
+	for (size_t f = 0; f < nfields; f++)
+	{
+	    size_t yofs = f * vstep;
+	    DrawScreenString(caption_x0, caption_y0 + yofs, caption[f]);
+	    DrawScreenBoxHollow(entry_box_x0,
+				entry_box_y0 + yofs,
+				entry_box_x0 + box_len[f] * FONTW +
+				2 * entry_hofs - 1, entry_box_y1 + yofs,
+				BLACK);
+	}
+	pop_colour();
+    }
+
+    /* Draw the foreground (the part that might
+       change as a result of the user actions). */
     for (size_t f = 0; f < nfields; f++)
     {
-      size_t yofs = f * vstep;
-      DrawScreenString (caption_x0, caption_y0 + yofs, caption[f]);
-      DrawScreenBoxHollow (entry_box_x0,
-			   entry_box_y0 + yofs,
-	  		   entry_box_x0 + box_len[f] * FONTW + 2*entry_hofs - 1,
-			   entry_box_y1 + yofs,
-			   BLACK);
+	if (!background_drawn || !entry_drawn[f])
+	{
+	    size_t l = strlen(buf[f]);
+	    int yofs = f * vstep;
+	    set_colour(BLACK);
+	    DrawScreenBox(entry_text_x0,
+			  entry_text_y0 + yofs,
+			  entry_text_x0 + box_len[f] * FONTW - 1,
+			  entry_text_y1 + yofs);
+	    set_colour(WINFG);
+	    if (l >= box_len[f])
+	    {
+		DrawScreenText(entry_text_x0, entry_text_y0 + yofs, "<%s",
+			       buf[f] + l - (box_len[f] - 2));
+	    }
+	    else
+		DrawScreenString(entry_text_x0, entry_text_y0 + yofs, buf[f]);
+	    if (f != field_no)
+		entry_drawn[f] = true;
+	}
     }
-    pop_colour ();
-  }
 
-  /* Draw the foreground (the part that might
-     change as a result of the user actions). */
-  for (size_t f = 0; f < nfields; f++)
-  {
-    if (! background_drawn || ! entry_drawn[f])
+    // Draw the cursor
+    if (!background_drawn || !entry_drawn[field_no])
     {
-      size_t l = strlen (buf[f]);
-      int yofs = f * vstep;
-      set_colour (BLACK);
-      DrawScreenBox (entry_text_x0,
-		     entry_text_y0 + yofs,
-		     entry_text_x0 + box_len[f] * FONTW - 1,
-		     entry_text_y1 + yofs);
-      set_colour (WINFG);
-      if (l >= box_len[f])
-      {
-	DrawScreenText (entry_text_x0, entry_text_y0 + yofs, "<%s",
-	  buf[f] + l - (box_len[f] - 2));
-      }
-      else
-	 DrawScreenString (entry_text_x0, entry_text_y0 + yofs, buf[f]);
-      if (f != field_no)
-        entry_drawn[f] = true;
+	push_colour(WINFG);
+	int cur_pos = strlen(buf[field_no]);
+	if (cur_pos >= box_len[field_no])
+	    cur_pos = box_len[field_no] - 1;
+	int x = entry_text_x0 + cur_pos * FONTW;
+	int y = entry_text_y0 + field_no * vstep;
+	DrawScreenBoxwh(x, y, FONTW, FONTH);
+	pop_colour();
+	entry_drawn[field_no] = true;
     }
-  }
 
-  // Draw the cursor
-  if (! background_drawn || ! entry_drawn[field_no])
-  {
-    push_colour (WINFG);
-    int cur_pos = strlen (buf[field_no]);
-    if (cur_pos >= box_len[field_no])
-      cur_pos = box_len[field_no] - 1;
-    int x = entry_text_x0 + cur_pos * FONTW;
-    int y = entry_text_y0 + field_no * vstep;
-    DrawScreenBoxwh (x, y, FONTW, FONTH);
-    pop_colour ();
-    entry_drawn[field_no] = true;
-  }
-
-  background_drawn = true;
+    background_drawn = true;
 }
 
 
@@ -368,15 +368,15 @@
  *	count_widget
  *	Return the number of widgets found in <fmt>.
  */
-int Entry2::count_widgets (const char *fmt)
+int Entry2::count_widgets(const char *fmt)
 {
-  int nwidgets = 0;
-  for (const char *p = fmt; *p; p++)
-  {
-    if (p[0] == '%' && p[1] != '%')
-      nwidgets++;
-  }
-  return nwidgets;
+    int nwidgets = 0;
+    for (const char *p = fmt; *p; p++)
+    {
+	if (p[0] == '%' && p[1] != '%')
+	    nwidgets++;
+    }
+    return nwidgets;
 }
 
 
@@ -385,288 +385,295 @@
  *	Parse <fmt> and fill in the widgets info arrays.
  *	Return 0 on success, non-zero on error.
  */
-int Entry2::fill_in_widgets_info (const char *fmt, va_list args)
+int Entry2::fill_in_widgets_info(const char *fmt, va_list args)
 {
-  size_t f = 0;
-  const char *last_literal = 0;
-  const int F_PLUS     = 1;
-  const int F_MINUS    = 2;
-  const int F_ZERO     = 4;
-  const int L_OMITTED  = 65535;
-  const int L_ASTERISK = 65534;
-  
-  /* First step: parse <fmt> and fill in
-     <box_len>, <buf_max_len>, <box_len>,
-     <caption> <entry_flags>. */
+    size_t f = 0;
+    const char *last_literal = 0;
+    const int F_PLUS = 1;
+    const int F_MINUS = 2;
+    const int F_ZERO = 4;
+    const int L_OMITTED = 65535;
+    const int L_ASTERISK = 65534;
 
-  for (const char *p = fmt;;)
-  {
-    if (*p == '%')
+    /* First step: parse <fmt> and fill in
+       <box_len>, <buf_max_len>, <box_len>,
+       <caption> <entry_flags>. */
+
+    for (const char *p = fmt;;)
     {
-      p++;
-      // Got %%
-      if (*p == '%')
-      {
-	if (! last_literal)
-	  last_literal = p - 1;
-	p++;
-	continue;
-      }
-      // Got a real %-field
-      if (f >= nfields)
-      {
-	printf ("Internal error: at offset %d in widget fmt \"%s\": more than"
-	    " %d fields.\nIgnoring excess field(s)\n",
-	    (int) (p - fmt), fmt, (int) f);
-	break;
-      }
-      int flags     = 0;
-      int length    = L_OMITTED;
-      int precision = L_OMITTED;
-      char type      = 0;
-      // Get the flag
-      for (;;)
-      {
-	if (*p == '+')
-	{
-	  flags |= F_PLUS;
-	  p++;
-	}
-	else if (*p == '-')
+	if (*p == '%')
 	{
-	  flags |= F_MINUS;
-	  p++;
-	}
-	else if (*p == '0')
-	{
-	  flags |= F_ZERO;
-	  p++;
-	}
-	else
-	  break;
-      }
-      // Get the optional length
-      if (*p == '*')
-      {
-	length = L_ASTERISK;
-	p++;
-      }
-      else if (isdigit ((unsigned char) *p))
-      {
-	length = 0;
-	while (isdigit ((unsigned char) *p))
-	  length = 10 * length + dectoi (*p++);
-      }
-      // Get the optional precision
-      if (*p == '.')
-      {
-	p++;
-	if (*p == '*')
-	{
-	  precision = L_ASTERISK;
-	  p++;
-	}
-	else if (! isdigit ((unsigned char) *p))
-	{
-	  printf ("Internal error: at offset %d in widget fmt \"%s\": bad"
-	      " precision spec \"%c\"\n", (int) (p - fmt), fmt, *p);
-	  break;
-	}
-	else
-	{
-	  precision = 0;
-	  while (isdigit ((unsigned char) *p))
-	    precision = 10 * precision + dectoi (*p++);
-	}
-      }
-      // Get the optional modifier (hh, h, l or Z)
-      _field_flags_t size = FF_INT;
-      if (*p == 'h')
-      {
-	if (p[1] == 'h')
-	{
-	  size = FF_CHAR;
-	  p += 2;
+	    p++;
+	    // Got %%
+	    if (*p == '%')
+	    {
+		if (!last_literal)
+		    last_literal = p - 1;
+		p++;
+		continue;
+	    }
+	    // Got a real %-field
+	    if (f >= nfields)
+	    {
+		printf
+		    ("Internal error: at offset %d in widget fmt \"%s\": more than"
+		     " %d fields.\nIgnoring excess field(s)\n",
+		     (int) (p - fmt), fmt, (int) f);
+		break;
+	    }
+	    int flags = 0;
+	    int length = L_OMITTED;
+	    int precision = L_OMITTED;
+	    char type = 0;
+	    // Get the flag
+	    for (;;)
+	    {
+		if (*p == '+')
+		{
+		    flags |= F_PLUS;
+		    p++;
+		}
+		else if (*p == '-')
+		{
+		    flags |= F_MINUS;
+		    p++;
+		}
+		else if (*p == '0')
+		{
+		    flags |= F_ZERO;
+		    p++;
+		}
+		else
+		    break;
+	    }
+	    // Get the optional length
+	    if (*p == '*')
+	    {
+		length = L_ASTERISK;
+		p++;
+	    }
+	    else if (isdigit((unsigned char) *p))
+	    {
+		length = 0;
+		while (isdigit((unsigned char) *p))
+		    length = 10 * length + dectoi(*p++);
+	    }
+	    // Get the optional precision
+	    if (*p == '.')
+	    {
+		p++;
+		if (*p == '*')
+		{
+		    precision = L_ASTERISK;
+		    p++;
+		}
+		else if (!isdigit((unsigned char) *p))
+		{
+		    printf
+			("Internal error: at offset %d in widget fmt \"%s\": bad"
+			 " precision spec \"%c\"\n", (int) (p - fmt), fmt,
+			 *p);
+		    break;
+		}
+		else
+		{
+		    precision = 0;
+		    while (isdigit((unsigned char) *p))
+			precision = 10 * precision + dectoi(*p++);
+		}
+	    }
+	    // Get the optional modifier (hh, h, l or Z)
+	    _field_flags_t size = FF_INT;
+	    if (*p == 'h')
+	    {
+		if (p[1] == 'h')
+		{
+		    size = FF_CHAR;
+		    p += 2;
+		}
+		else
+		{
+		    size = FF_SHORT;
+		    p++;
+		}
+	    }
+	    else if (*p == 'Z')
+	    {
+		size = FF_SIZE_T;
+		p++;
+	    }
+	    else if (*p == 'l')
+	    {
+		size = FF_LONG;
+		p++;
+	    }
+	    // Get the type (diousSxX)
+	    if (*p == 'd' || *p == 'i' || *p == 'o' || *p == 'x' || *p == 'X')
+		type = 'd';
+	    else if (*p == 'u')
+		type = 'u';
+	    else if (*p == 's')
+		type = 's';
+	    else if (*p == 'S')
+		type = 'S';
+	    else
+	    {
+		printf
+		    ("Internal error: at offset %d in widget fmt \"%s\": bad"
+		     " format \"%c\"\n", (int) (p - fmt), fmt, *p);
+		continue;
+	    }
+	    p++;
+
+	    /* Fill in <entry_flags> and <caption> and
+	       also <box_len> and <buf_max_len> if
+	       they're explicit. */
+	    box_len[f] = precision;
+	    buf[f] = 0;
+	    buf_max_len[f] = length;
+	    if (type == 'd')
+		entry_flags[f] =
+		    (_field_flags_t) (FF_ENTRY | FF_INTEGER | FF_SIGNED);
+	    else if (type == 'u')
+		entry_flags[f] = (_field_flags_t) (FF_ENTRY | FF_INTEGER);
+	    else if (type == 's' || type == 'S')
+	    {
+		entry_flags[f] = (_field_flags_t) (FF_ENTRY | FF_STRING);
+		if (type == 'S')
+		    entry_flags[f] =
+			(_field_flags_t) (entry_flags[f] | FF_UPPERCASE);
+		if (flags & F_PLUS)
+		    entry_flags[f] =
+			(_field_flags_t) (entry_flags[f] | FF_NONEMPTY);
+	    }
+	    else
+		entry_flags[f] = (_field_flags_t) 0;	// Ouch !
+	    caption[f] = last_literal;
+
+	    // On to the next field
+	    f++;
+	    last_literal = 0;
 	}
 	else
 	{
-	  size = FF_SHORT;
-	  p++;
+	    if (*p == '\0')
+		break;
+	    if (!last_literal)
+		last_literal = p;
+	    p++;
 	}
-      }
-      else if (*p == 'Z')
-      {
-	size = FF_SIZE_T;
-	p++;
-      }
-      else if (*p == 'l')
-      {
-	size = FF_LONG;
-	p++;
-      }
-      // Get the type (diousSxX)
-      if (*p == 'd' || *p == 'i' || *p == 'o' || *p == 'x' || *p == 'X')
-	type = 'd';
-      else if (*p == 'u')
-	type = 'u';
-      else if (*p == 's')
-	type = 's';
-      else if (*p == 'S')
-	type = 'S';
-      else
-      {
-	printf ("Internal error: at offset %d in widget fmt \"%s\": bad"
-	    " format \"%c\"\n", (int) (p - fmt), fmt, *p);
-	continue;
-      }
-      p++;
+    }
 
-      /* Fill in <entry_flags> and <caption> and
-	 also <box_len> and <buf_max_len> if
-	 they're explicit. */
-      box_len[f] = precision;
-      buf[f] = 0;
-      buf_max_len[f] = length;
-      if (type == 'd')
-	entry_flags[f] = (_field_flags_t) (FF_ENTRY | FF_INTEGER | FF_SIGNED);
-      else if (type == 'u')
-	entry_flags[f] = (_field_flags_t) (FF_ENTRY | FF_INTEGER);
-      else if (type == 's' || type == 'S')
-      {
-	entry_flags[f] = (_field_flags_t) (FF_ENTRY | FF_STRING);
-	if (type == 'S')
-	  entry_flags[f] = (_field_flags_t) (entry_flags[f] | FF_UPPERCASE);
-	if (flags & F_PLUS)
-	  entry_flags[f] = (_field_flags_t) (entry_flags[f] | FF_NONEMPTY);
-      }
-      else
-	entry_flags[f] = (_field_flags_t) 0;  // Ouch !
-      caption[f]     = last_literal;
-
-      // On to the next field
-      f++;
-      last_literal = 0;
-    }
-    else
+    /* Second phase: retrieve the arguments from
+       the list and fill in <buf> and perhaps also
+       <box_len> and <buf_max_len> if needed. */
+    for (size_t f = 0; f < nfields; f++)
     {
-      if (*p == '\0')
-	break;
-      if (! last_literal)
-	last_literal = p;
-      p++;
-    }
-  }
+	// "%*": retrieve the length
+	if (buf_max_len[f] == L_ASTERISK)
+	    buf_max_len[f] = va_arg(args, size_t);
 
-  /* Second phase: retrieve the arguments from
-     the list and fill in <buf> and perhaps also
-     <box_len> and <buf_max_len> if needed. */
-  for (size_t f = 0; f < nfields; f++)
-  {
-    // "%*": retrieve the length
-    if (buf_max_len[f] == L_ASTERISK)
-      buf_max_len[f] = va_arg (args, size_t);
-
-    // "%.*": retrieve the precision
-    if (box_len[f] == L_ASTERISK)
-      box_len[f] = va_arg (args, size_t);
+	// "%.*": retrieve the precision
+	if (box_len[f] == L_ASTERISK)
+	    box_len[f] = va_arg(args, size_t);
 
-    // Retrieve the pointer on the buffer
-    if ((entry_flags[f] & FF_TYPE) == FF_ENTRY)
-    {
-      if ((entry_flags[f] & FF_SUBTYPE) == FF_STRING)
-      {
-        buf[f] = va_arg (args, char *);
-        if (buf_max_len[f] == L_OMITTED)
-	  buf_max_len[f] = strlen (buf[f]);  // Bletch !
-	if (box_len[f] == L_OMITTED)
-	  box_len[f] = y_min (buf_max_len[f], 30);
-      }
-      else if ((entry_flags[f] & FF_SUBTYPE) == FF_INTEGER)
-      {
-	switch (entry_flags[f] & FF_INTSIZE)
+	// Retrieve the pointer on the buffer
+	if ((entry_flags[f] & FF_TYPE) == FF_ENTRY)
 	{
-	  case FF_CHAR :
-	    buf[f] = (char *) va_arg (args, char *);
-	    break;
-	  case FF_SHORT :
-	    buf[f] = (char *) va_arg (args, short *);
-	    break;
-	  case FF_INT :
-	    buf[f] = (char *) va_arg (args, int *);
-	    break;
-	  case FF_SIZE_T :
-	    buf[f] = (char *) va_arg (args, size_t *);
-	    break;
-	  case FF_LONG :
-	    buf[f] = (char *) va_arg (args, long *);
-	    break;
-	  default :
-	    ;  // FIXME
+	    if ((entry_flags[f] & FF_SUBTYPE) == FF_STRING)
+	    {
+		buf[f] = va_arg(args, char *);
+		if (buf_max_len[f] == L_OMITTED)
+		    buf_max_len[f] = strlen(buf[f]);	// Bletch !
+		if (box_len[f] == L_OMITTED)
+		    box_len[f] = y_min(buf_max_len[f], 30);
+	    }
+	    else if ((entry_flags[f] & FF_SUBTYPE) == FF_INTEGER)
+	    {
+		switch (entry_flags[f] & FF_INTSIZE)
+		{
+		case FF_CHAR:
+		    buf[f] = (char *) va_arg(args, char *);
+		    break;
+		case FF_SHORT:
+		    buf[f] = (char *) va_arg(args, short *);
+		    break;
+		case FF_INT:
+		    buf[f] = (char *) va_arg(args, int *);
+		    break;
+		case FF_SIZE_T:
+		    buf[f] = (char *) va_arg(args, size_t *);
+		    break;
+		case FF_LONG:
+		    buf[f] = (char *) va_arg(args, long *);
+		    break;
+		default:
+		    ;		// FIXME
+		}
+	    }
+	    else;		// FIXME
 	}
-      }
-      else 
-	;  // FIXME
+	else;			// To be implemented later
     }
-    else
-      ;  // To be implemented later
-  }
-  return 0;
+    return 0;
 }
 
- 
+
 /*
  *	do_geom
  *	Do geometry computations
  */
-void Entry2::do_geom ()
+void Entry2::do_geom()
 {
-  // Compute the widths
-  size_t title_len = strlen (title);	// Length of title
-  size_t entry_len = 0;			// Length or longest entry
-  for (size_t f = 0; f < nfields; f++)
-  {
-    size_t l = box_len[f];
-    if (l > entry_len)
-      entry_len = l;
-  }
-  size_t caption_len = 0;		// Length of longest caption
-  for (size_t f = 0; f < nfields; f++)
-  {
-    size_t l = strlen (caption[f]);
-    if (l > caption_len)
-      caption_len = l;
-  }
-  size_t entry_width  = FONTW * entry_len + 2 * entry_hofs;
-  size_t caption_width= FONTW * caption_len + WIDE_HSPACING;
-  size_t inner_width  = y_max (entry_width + caption_width, FONTW * title_len);
-  size_t outer_width  = inner_width  + 2 * win_hofs;
+    // Compute the widths
+    size_t title_len = strlen(title);	// Length of title
+    size_t entry_len = 0;	// Length or longest entry
+    for (size_t f = 0; f < nfields; f++)
+    {
+	size_t l = box_len[f];
+	if (l > entry_len)
+	    entry_len = l;
+    }
+    size_t caption_len = 0;	// Length of longest caption
+    for (size_t f = 0; f < nfields; f++)
+    {
+	size_t l = strlen(caption[f]);
+	if (l > caption_len)
+	    caption_len = l;
+    }
+    size_t entry_width = FONTW * entry_len + 2 * entry_hofs;
+    size_t caption_width = FONTW * caption_len + WIDE_HSPACING;
+    size_t inner_width =
+	y_max(entry_width + caption_width, FONTW * title_len);
+    size_t outer_width = inner_width + 2 * win_hofs;
 
-  // Compute the heights
-  vstep = FONTH + 2 * entry_vofs + BOX_VSPACING;
-  size_t inner_height = nfields * vstep - BOX_VSPACING + title_vspacing + FONTH;
-  size_t outer_height = inner_height + 2 * win_vofs;
+    // Compute the heights
+    vstep = FONTH + 2 * entry_vofs + BOX_VSPACING;
+    size_t inner_height =
+	nfields * vstep - BOX_VSPACING + title_vspacing + FONTH;
+    size_t outer_height = inner_height + 2 * win_vofs;
 
-  // Compute the absolute coordinates
-  if (win_x0 < 0)
-     win_x0 = (ScrMaxX - outer_width) / 2;
-  if (win_y0 < 0)
-     win_y0 = (ScrMaxY - outer_height) / 2;
-  win_x1        = win_x0 + outer_width - 1;
-  win_y1        = win_y0 + outer_height - 1;
-  title_x0      = win_x0 + win_hofs;
-  title_y0      = win_y0 + win_vofs;
-  entry_box_y0  = title_y0 + FONTH + title_vspacing;
-  entry_text_y0 = entry_box_y0 + entry_vofs;
-  entry_text_y1 = entry_text_y0 + FONTH - 1;
-  entry_box_y1  = entry_text_y1 + entry_vofs;
-  caption_y0    = entry_text_y0;
-  caption_x0    = title_x0;
-  entry_box_x0  = caption_x0 + caption_width;
-  entry_text_x0 = entry_box_x0 + entry_hofs;
-  entry_text_x1 = entry_text_x0 + entry_len * FONTW - 1;  // Unused
-  entry_box_x1  = entry_text_x1 + entry_hofs;             // Unused
+    // Compute the absolute coordinates
+    if (win_x0 < 0)
+	win_x0 = (ScrMaxX - outer_width) / 2;
+    if (win_y0 < 0)
+	win_y0 = (ScrMaxY - outer_height) / 2;
+    win_x1 = win_x0 + outer_width - 1;
+    win_y1 = win_y0 + outer_height - 1;
+    title_x0 = win_x0 + win_hofs;
+    title_y0 = win_y0 + win_vofs;
+    entry_box_y0 = title_y0 + FONTH + title_vspacing;
+    entry_text_y0 = entry_box_y0 + entry_vofs;
+    entry_text_y1 = entry_text_y0 + FONTH - 1;
+    entry_box_y1 = entry_text_y1 + entry_vofs;
+    caption_y0 = entry_text_y0;
+    caption_x0 = title_x0;
+    entry_box_x0 = caption_x0 + caption_width;
+    entry_text_x0 = entry_box_x0 + entry_hofs;
+    entry_text_x1 = entry_text_x0 + entry_len * FONTW - 1;	// Unused
+    entry_box_x1 = entry_text_x1 + entry_hofs;	// Unused
 
-  geom_up_to_date = true;
+    geom_up_to_date = true;
 }
 
 
@@ -674,50 +681,49 @@
  *	jump_to_field
  *	Jump to a particular field
  */
-void Entry2::jump_to_field (size_t field_no)
+void Entry2::jump_to_field(size_t field_no)
 {
-  if (field_no >= nfields)
-  {
-    printf ("Internal error: Entry2::jump_to_field %d (nf=%d)",
-	(int) field_no, (int) nfields);
-    return;
-  }
-  entry_drawn[this->field_no] = false;
-  entry_drawn[field_no] = false;
-  this->field_no = field_no;
-  first_key = 1;
+    if (field_no >= nfields)
+    {
+	printf("Internal error: Entry2::jump_to_field %d (nf=%d)",
+	       (int) field_no, (int) nfields);
+	return;
+    }
+    entry_drawn[this->field_no] = false;
+    entry_drawn[field_no] = false;
+    this->field_no = field_no;
+    first_key = 1;
 }
 
 
 /*
  *	prev_field
  */
-void Entry2::prev_field ()
+void Entry2::prev_field()
 {
-  if (nfields < 1)
-    return;
-  size_t f = field_no;
-  if (f < 1)
-    f = nfields - 1;
-  else
-    f--;
-  jump_to_field (f);
+    if (nfields < 1)
+	return;
+    size_t f = field_no;
+    if (f < 1)
+	f = nfields - 1;
+    else
+	f--;
+    jump_to_field(f);
 }
 
 
 /*
  *	next_field
  */
-void Entry2::next_field ()
+void Entry2::next_field()
 {
-  if (nfields < 1)
-    return;
-  size_t f = field_no + 1;
-  if (f >= nfields)
-    f = 0;
-  jump_to_field (f);
+    if (nfields < 1)
+	return;
+    size_t f = field_no + 1;
+    if (f >= nfields)
+	f = 0;
+    jump_to_field(f);
 }
 
 
 /* TEST STUFF FOLLOWS */
-
--- a/src/entry2.h	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/entry2.h	Sat Sep 24 14:16:04 2011 +0300
@@ -5,65 +5,61 @@
  */
 
 
-#ifndef YH_ENTRY2  /* To prevent multiple inclusion */
-#define YH_ENTRY2  /* To prevent multiple inclusion */
+#ifndef YH_ENTRY2		/* To prevent multiple inclusion */
+#define YH_ENTRY2		/* To prevent multiple inclusion */
 
 
 typedef enum
 {
-  ACT_NONE,
-  ACT_VALID,
-  ACT_CANCEL
+    ACT_NONE,
+    ACT_VALID,
+    ACT_CANCEL
 } Entry2_action_t;
 
 
 class Entry2
 {
-  typedef enum  // Strictly private to the class
-  {
-    FF_TYPE      = 0xf000,  // Type mask
-      FF_ENTRY   = 0x0000,  //   Entry
-      FF_CHECK   = 0x1000,  //   Check button (unimplemented)
-      FF_RADIO   = 0x2000,  //   Radio button (unimplemented)
-      FF_BUTTON  = 0x3000,  //   Button (unimplemented)
-    FF_SUBTYPE   = 0x0f00,  // Subtype mask
-      FF_STRING  = 0x0000,  //   Entry: String entry
-      FF_INTEGER = 0x0100,  //   Entry: Integer entry
-    FF_UPPERCASE = 0x0001,  // String entry: upper-case everything
-    FF_NONEMPTY  = 0x0002,  // String entry: can't be empty
-    FF_SIGNED    = 0x0001,  // Integer entry: it can be signed (unimplemented)
-    FF_INTSIZE   = 0x000e,  // Integer entry: size mask
-      FF_CHAR    = 0x0000,  //   char (signed or unsigned)
-      FF_SHORT   = 0x0002,  //   short (signed or unsigned)
-      FF_INT     = 0x0004,  //   int  (signed or unsigned)
-      FF_SIZE_T  = 0x0006,  //   size_t
-      FF_LONG    = 0x0008,  //   long (signed or unsigned)
-    FF__
-  } _field_flags_t;
+    typedef enum		// Strictly private to the class
+    {
+	FF_TYPE = 0xf000,	// Type mask
+	FF_ENTRY = 0x0000,	//   Entry
+	FF_CHECK = 0x1000,	//   Check button (unimplemented)
+	FF_RADIO = 0x2000,	//   Radio button (unimplemented)
+	FF_BUTTON = 0x3000,	//   Button (unimplemented)
+	FF_SUBTYPE = 0x0f00,	// Subtype mask
+	FF_STRING = 0x0000,	//   Entry: String entry
+	FF_INTEGER = 0x0100,	//   Entry: Integer entry
+	FF_UPPERCASE = 0x0001,	// String entry: upper-case everything
+	FF_NONEMPTY = 0x0002,	// String entry: can't be empty
+	FF_SIGNED = 0x0001,	// Integer entry: it can be signed (unimplemented)
+	FF_INTSIZE = 0x000e,	// Integer entry: size mask
+	FF_CHAR = 0x0000,	//   char (signed or unsigned)
+	FF_SHORT = 0x0002,	//   short (signed or unsigned)
+	FF_INT = 0x0004,	//   int  (signed or unsigned)
+	FF_SIZE_T = 0x0006,	//   size_t
+	FF_LONG = 0x0008,	//   long (signed or unsigned)
+	FF__
+    } _field_flags_t;
 
-  public :
-
-    Entry2 (const char *title, const char *fmt, ...);
-    ~Entry2 ();
-    int loop ();
-    Entry2_action_t process_event (const input_status_t &is);
-    void refresh ();
+      public:Entry2(const char *title, const char *fmt, ...);
+     ~Entry2();
+    int loop();
+    Entry2_action_t process_event(const input_status_t & is);
+    void refresh();
 
-  private :
-
-    int count_widgets (const char *fmt);
-    int fill_in_widgets_info (const char *fmt, va_list args);
-    void do_geom ();
-    void jump_to_field (size_t field_no);
-    void prev_field ();
-    void next_field ();
+      private: int count_widgets(const char *fmt);
+    int fill_in_widgets_info(const char *fmt, va_list args);
+    void do_geom();
+    void jump_to_field(size_t field_no);
+    void prev_field();
+    void next_field();
 
     // Per-field data
-    unsigned short  *box_len;
-    char           **buf;
-    unsigned short  *buf_max_len;
-    const char     **caption;
-    bool            *entry_drawn;
+    unsigned short *box_len;
+    char **buf;
+    unsigned short *buf_max_len;
+    const char **caption;
+    bool *entry_drawn;
     _field_flags_t *entry_flags;
 
     // Input
@@ -105,18 +101,18 @@
     int entry_text_y1;
 
     // Convenience functions.
-    bool is_integer_entry (_field_flags_t flags)
+    bool is_integer_entry(_field_flags_t flags)
     {
-      return (flags & FF_TYPE) == FF_ENTRY
-	&& (flags & FF_SUBTYPE) == FF_INTEGER;
+	return (flags & FF_TYPE) == FF_ENTRY
+	    && (flags & FF_SUBTYPE) == FF_INTEGER;
     }
 
-    bool is_string_entry (_field_flags_t flags)
+    bool is_string_entry(_field_flags_t flags)
     {
-      return (flags & FF_TYPE) == FF_ENTRY
-	&& (flags & FF_SUBTYPE) == FF_STRING;
+	return (flags & FF_TYPE) == FF_ENTRY
+	    && (flags & FF_SUBTYPE) == FF_STRING;
     }
 };
 
 
-#endif  /* DO NOT ADD ANYTHING AFTER THIS LINE */
+#endif /* DO NOT ADD ANYTHING AFTER THIS LINE */
--- a/src/events.cc	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/events.cc	Sat Sep 24 14:16:04 2011 +0300
@@ -61,22 +61,22 @@
 /*
  *
  */
-void init_event ()
+void init_event()
 {
-  head = 0;
-  events_in_queue = 0;
+    head = 0;
+    events_in_queue = 0;
 }
 
 
 /*
  *
  */
-void send_event (int event)
+void send_event(int event)
 {
-  if (events_in_queue == Y_EVENT_QUEUE)
-    fatal_error ("Event buffer full");
-  event_queue[(head + events_in_queue) % Y_EVENT_QUEUE] = event;
-  events_in_queue++;
+    if (events_in_queue == Y_EVENT_QUEUE)
+	fatal_error("Event buffer full");
+    event_queue[(head + events_in_queue) % Y_EVENT_QUEUE] = event;
+    events_in_queue++;
 }
 
 
@@ -84,9 +84,9 @@
  *	has_event
  *	Is there any event at all ?
  */
-int has_event ()
+int has_event()
 {
-  return events_in_queue != 0;
+    return events_in_queue != 0;
 }
 
 
@@ -94,10 +94,9 @@
  *	has_event
  *	Is there an event of that type ?
  */
-int has_event (int event)
+int has_event(int event)
 {
-  return events_in_queue != 0
-    && event_queue[head] == event;
+    return events_in_queue != 0 && event_queue[head] == event;
 }
 
 
@@ -106,11 +105,11 @@
  *	Is there an YK_* event ?
  *	FIXME should create YE_KEY_PRESS and delete this function.
  */
-int has_key_press_event ()
+int has_key_press_event()
 {
-  return events_in_queue != 0
-    && event_queue[head]
-    && (event_queue[head] & ~ (YK_ALT | YK_CTRL | YK_SHIFT)) < YK__LAST;
+    return events_in_queue != 0
+	&& event_queue[head]
+	&& (event_queue[head] & ~(YK_ALT | YK_CTRL | YK_SHIFT)) < YK__LAST;
 }
 
 
@@ -118,19 +117,15 @@
  *	get_event
  *	Get the next event
  */
-int get_event ()
+int get_event()
 {
-  if (events_in_queue == 0)  // The buffer is empty
-    return 0;
+    if (events_in_queue == 0)	// The buffer is empty
+	return 0;
 
-  int e = event_queue[head];
-  events_in_queue--;
-  head++;
-  if (head == Y_EVENT_QUEUE)
-    head = 0;
-  return e;
+    int e = event_queue[head];
+    events_in_queue--;
+    head++;
+    if (head == Y_EVENT_QUEUE)
+	head = 0;
+    return e;
 }
-
-
-
-
--- a/src/events.h	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/events.h	Sat Sep 24 14:16:04 2011 +0300
@@ -11,11 +11,9 @@
 It's still _only_ an idea ; this API is bogus.
 */
 
-void init_event ();
-void send_event (int);
-int has_event ();
-int has_event (int);
-int has_key_press_event ();
-int get_event ();
-
-
+void init_event();
+void send_event(int);
+int has_event();
+int has_event(int);
+int has_key_press_event();
+int get_event();
--- a/src/flats.cc	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/flats.cc	Sat Sep 24 14:16:04 2011 +0300
@@ -46,19 +46,21 @@
    FIXME the <list> and <listsize> parameters are ignored since 1999-07-10.
 */
 
-void ChooseFloorTexture (int x0, int y0, const char *prompt, int listsize, char **list, char *name)
+void ChooseFloorTexture(int x0, int y0, const char *prompt, int listsize,
+			char **list, char *name)
 {
-  (void) list;
-  (void) listsize;
-  // Build a list of char *, for InputNameFromListWithFunc()'s sake
-  char **flat_names = (char **) GetMemory (NumFTexture * sizeof *flat_names);
-  for (size_t n = 0; n < NumFTexture; n++)
-    flat_names[n] = flat_list[n].name;
+    (void) list;
+    (void) listsize;
+    // Build a list of char *, for InputNameFromListWithFunc()'s sake
+    char **flat_names = (char **) GetMemory(NumFTexture * sizeof *flat_names);
+    for (size_t n = 0; n < NumFTexture; n++)
+	flat_names[n] = flat_list[n].name;
 
-  InputNameFromListWithFunc (x0, y0, prompt, (size_t) NumFTexture, flat_names,
-    5, name, 64, 64, DisplayFloorTexture);
+    InputNameFromListWithFunc(x0, y0, prompt, (size_t) NumFTexture,
+			      flat_names, 5, name, 64, 64,
+			      DisplayFloorTexture);
 
-  FreeMemory (flat_names);
+    FreeMemory(flat_names);
 }
 
 
@@ -67,11 +69,11 @@
  *	Function used by bsearch() to locate a particular 
  *	flat in the FTexture.
  */
-static int flat_list_entry_match (const void *key, const void *flat_list_entry)
+static int flat_list_entry_match(const void *key, const void *flat_list_entry)
 {
-  return y_strnicmp ((const char *) key,
-    ((const flat_list_entry_t *) flat_list_entry)->name,
-    WAD_FLAT_NAME);
+    return y_strnicmp((const char *) key,
+		      ((const flat_list_entry_t *) flat_list_entry)->name,
+		      WAD_FLAT_NAME);
 }
 
 
@@ -80,56 +82,56 @@
    and not beyond c->x1, c->y1
 */
 
-void DisplayFloorTexture (hookfunc_comm_t *c)
+void DisplayFloorTexture(hookfunc_comm_t * c)
 {
-  c->width  = DOOM_FLAT_WIDTH;  // Big deal !
-  c->height = DOOM_FLAT_HEIGHT;
-  c->flags  = HOOK_SIZE_VALID;
+    c->width = DOOM_FLAT_WIDTH;	// Big deal !
+    c->height = DOOM_FLAT_HEIGHT;
+    c->flags = HOOK_SIZE_VALID;
 
-  flat_list_entry_t *flat = (flat_list_entry_t *)
-    bsearch (c->name, flat_list, NumFTexture, sizeof *flat_list,
-	flat_list_entry_match);
-  if (flat == 0)  // Not found in list
-  {
-    push_colour (WINBG);
-    DrawScreenBox (c->x0, c->y0, c->x1, c->y1);
-    set_colour (WINFG_DIM);
-    DrawScreenLine (c->x0, c->y0, c->x1, c->y1);
-    DrawScreenLine (c->x0, c->y1, c->x1, c->y0);
-    pop_colour ();
-    return;
-  }
-  c->lump_loc.wad = flat->wadfile;
-  c->lump_loc.ofs = flat->offset;
-  c->lump_loc.len = DOOM_FLAT_WIDTH * DOOM_FLAT_HEIGHT;  // Sorry.
-  c->flags |= HOOK_LOC_VALID;
-  const Wad_file *wadfile = flat->wadfile;
-  wadfile->seek (flat->offset);
-  if (wadfile->error ())
-  {
-    warn ("%s: can't seek to %lXh\n",
-	wadfile->pathname (), (unsigned long) flat->offset);
-    warn ("%.8s: seek error\n", c->name);
-  }
+    flat_list_entry_t *flat = (flat_list_entry_t *)
+	bsearch(c->name, flat_list, NumFTexture, sizeof *flat_list,
+		flat_list_entry_match);
+    if (flat == 0)		// Not found in list
+    {
+	push_colour(WINBG);
+	DrawScreenBox(c->x0, c->y0, c->x1, c->y1);
+	set_colour(WINFG_DIM);
+	DrawScreenLine(c->x0, c->y0, c->x1, c->y1);
+	DrawScreenLine(c->x0, c->y1, c->x1, c->y0);
+	pop_colour();
+	return;
+    }
+    c->lump_loc.wad = flat->wadfile;
+    c->lump_loc.ofs = flat->offset;
+    c->lump_loc.len = DOOM_FLAT_WIDTH * DOOM_FLAT_HEIGHT;	// Sorry.
+    c->flags |= HOOK_LOC_VALID;
+    const Wad_file *wadfile = flat->wadfile;
+    wadfile->seek(flat->offset);
+    if (wadfile->error())
+    {
+	warn("%s: can't seek to %lXh\n",
+	     wadfile->pathname(), (unsigned long) flat->offset);
+	warn("%.8s: seek error\n", c->name);
+    }
 
-  c->img.resize (c->width, c->height);
-  c->img.set_opaque (true);
-  long nbytes = (long) c->width * c->height;
-  wadfile->read_bytes (c->img.wbuf (), nbytes);
-  if (wadfile->error ())
-  {
-    warn ("%s: read error\n", wadfile->where ());
-    warn ("%.8s: short read\n", c->name);
-  }
-  Sticker sticker (c->img, true);  // Use opaque because it's faster
-  sticker.draw (drw, 't', c->x0, c->y0);
+    c->img.resize(c->width, c->height);
+    c->img.set_opaque(true);
+    long nbytes = (long) c->width * c->height;
+    wadfile->read_bytes(c->img.wbuf(), nbytes);
+    if (wadfile->error())
+    {
+	warn("%s: read error\n", wadfile->where());
+	warn("%.8s: short read\n", c->name);
+    }
+    Sticker sticker(c->img, true);	// Use opaque because it's faster
+    sticker.draw(drw, 't', c->x0, c->y0);
 
-  c->disp_x0 = c->x0;
-  c->disp_y0 = c->y0;
-  c->disp_x1 = c->x1;
-  c->disp_y1 = c->y1;
+    c->disp_x0 = c->x0;
+    c->disp_y0 = c->y0;
+    c->disp_x1 = c->x1;
+    c->disp_y1 = c->y1;
 
-  c->flags |= HOOK_DRAWN;
+    c->flags |= HOOK_DRAWN;
 }
 
 
@@ -137,20 +139,17 @@
  *	display_flat_depressed
  *	Display a flat inside a hollow box
  */
-void display_flat_depressed (hookfunc_comm_t *c)
+void display_flat_depressed(hookfunc_comm_t * c)
 {
-  draw_box_border (c->x0, c->y0, c->x1 - c->x0 + 1, c->y1 - c->y0 + 1,
-    HOLLOW_BORDER, 0);
-  c->x0 += HOLLOW_BORDER;
-  c->y0 += HOLLOW_BORDER;
-  c->x1 -= HOLLOW_BORDER;
-  c->y1 -= HOLLOW_BORDER;
-  DisplayFloorTexture (c);
-  c->x0 -= HOLLOW_BORDER;
-  c->y0 -= HOLLOW_BORDER;
-  c->x1 += HOLLOW_BORDER;
-  c->y1 += HOLLOW_BORDER;
+    draw_box_border(c->x0, c->y0, c->x1 - c->x0 + 1, c->y1 - c->y0 + 1,
+		    HOLLOW_BORDER, 0);
+    c->x0 += HOLLOW_BORDER;
+    c->y0 += HOLLOW_BORDER;
+    c->x1 -= HOLLOW_BORDER;
+    c->y1 -= HOLLOW_BORDER;
+    DisplayFloorTexture(c);
+    c->x0 -= HOLLOW_BORDER;
+    c->y0 -= HOLLOW_BORDER;
+    c->x1 += HOLLOW_BORDER;
+    c->y1 += HOLLOW_BORDER;
 }
-
-
-
--- a/src/flats.h	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/flats.h	Sat Sep 24 14:16:04 2011 +0300
@@ -4,16 +4,16 @@
  */
 
 
-#ifndef YH_FLATS  /* DO NOT INSERT ANYTHING BEFORE THIS LINE */
+#ifndef YH_FLATS		/* DO NOT INSERT ANYTHING BEFORE THIS LINE */
 #define YH_FLATS
 
 
 #include "lists.h"
 
 
-void ChooseFloorTexture (int, int, const char *, int, char **, char *);
-void DisplayFloorTexture (hookfunc_comm_t *c);
-void display_flat_depressed (hookfunc_comm_t *c);
+void ChooseFloorTexture(int, int, const char *, int, char **, char *);
+void DisplayFloorTexture(hookfunc_comm_t * c);
+void display_flat_depressed(hookfunc_comm_t * c);
 
 
-#endif  /* DO NOT ADD ANYTHING AFTER THIS LINE */
+#endif /* DO NOT ADD ANYTHING AFTER THIS LINE */
--- a/src/game.cc	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/game.cc	Sat Sep 24 14:16:04 2011 +0300
@@ -44,13 +44,13 @@
  *	InitGameDefs
  *	Create empty lists for game definitions
  */
-void InitGameDefs (void)
+void InitGameDefs(void)
 {
-ldtdef      = al_lcreate (sizeof (ldtdef_t    ));
-ldtgroup    = al_lcreate (sizeof (ldtgroup_t  ));
-stdef       = al_lcreate (sizeof (stdef_t     ));
-thingdef    = al_lcreate (sizeof (thingdef_t  ));
-thinggroup  = al_lcreate (sizeof (thinggroup_t));
+    ldtdef = al_lcreate(sizeof(ldtdef_t));
+    ldtgroup = al_lcreate(sizeof(ldtgroup_t));
+    stdef = al_lcreate(sizeof(stdef_t));
+    thingdef = al_lcreate(sizeof(thingdef_t));
+    thinggroup = al_lcreate(sizeof(thinggroup_t));
 }
 
 
@@ -60,296 +60,300 @@
  *	Builds list ThingsDefs.
  *	A totally boring piece of code.
  */
-void LoadGameDefs (const char *game)
+void LoadGameDefs(const char *game)
 {
-FILE *ygdfile = 0;		/* YGD file descriptor */
+    FILE *ygdfile = 0;		/* YGD file descriptor */
 #define YGD_BUF 200		/* max. line length + 2 */
-char readbuf[YGD_BUF];		/* buffer the line is read into */
+    char readbuf[YGD_BUF];	/* buffer the line is read into */
 #define MAX_TOKENS 10		/* tokens per line */
-int lineno;			/* current line of file */
-char filename[1025];
-char basename[256];
+    int lineno;			/* current line of file */
+    char filename[1025];
+    char basename[256];
 
-al_scps (basename, game,   sizeof basename - 1);
-al_saps (basename, ".ygd", sizeof basename - 1);
+    al_scps(basename, game, sizeof basename - 1);
+    al_saps(basename, ".ygd", sizeof basename - 1);
 
 /* Locate the game definition file. */
-{
-   Locate locate (yadex_share_path, basename, false);
-   const char *pathname = locate.get_next ();
-   if (pathname == NULL)
-      fatal_error ("Game definition file \"%s\" not found", basename);
-   if (strlen (pathname) > sizeof filename - 1)
-      fatal_error ("%s: file name too long");
-   strcpy (filename, pathname);
-   printf ("Reading game definition file \"%s\".\n", filename);
-}
+    {
+	Locate locate(yadex_share_path, basename, false);
+	const char *pathname = locate.get_next();
+	if (pathname == NULL)
+	    fatal_error("Game definition file \"%s\" not found", basename);
+	if (strlen(pathname) > sizeof filename - 1)
+	    fatal_error("%s: file name too long");
+	strcpy(filename, pathname);
+	printf("Reading game definition file \"%s\".\n", filename);
+    }
 
-ygdfile = fopen (filename, "r");
-if (ygdfile == NULL)
-   fatal_error ("%s: %s", filename, strerror (errno));
+    ygdfile = fopen(filename, "r");
+    if (ygdfile == NULL)
+	fatal_error("%s: %s", filename, strerror(errno));
 
 /* The first line of the ygd file must
    contain exactly ygd_file_magic. */
-if (fgets (readbuf, sizeof readbuf, ygdfile) == NULL
-   || memcmp (readbuf, ygd_file_magic, sizeof ygd_file_magic - 1)
-   || readbuf[sizeof ygd_file_magic - 1] != '\n'
-   || readbuf[sizeof ygd_file_magic] != '\0')
-   {
-   err ("%s is not a valid Yadex game definition file", filename);
-   fatal_error ("Perhaps a leftover from a previous version of Yadex ?");
-   }
+    if (fgets(readbuf, sizeof readbuf, ygdfile) == NULL
+	|| memcmp(readbuf, ygd_file_magic, sizeof ygd_file_magic - 1)
+	|| readbuf[sizeof ygd_file_magic - 1] != '\n'
+	|| readbuf[sizeof ygd_file_magic] != '\0')
+    {
+	err("%s is not a valid Yadex game definition file", filename);
+	fatal_error("Perhaps a leftover from a previous version of Yadex ?");
+    }
 
 /* Read the game definition
    file, line by line. */
-for (lineno = 2; fgets (readbuf, sizeof readbuf, ygdfile); lineno++)
-   {
-   int         ntoks;
-   char       *token[MAX_TOKENS];
-   int         quoted;
-   int         in_token;
-   const char *iptr;
-   char       *optr;
-   char       *buf;
-   const char *const bad_arg_count =
-                                "%s(%d): directive \"%s\" takes %d parameters";
+    for (lineno = 2; fgets(readbuf, sizeof readbuf, ygdfile); lineno++)
+    {
+	int ntoks;
+	char *token[MAX_TOKENS];
+	int quoted;
+	int in_token;
+	const char *iptr;
+	char *optr;
+	char *buf;
+	const char *const bad_arg_count =
+	    "%s(%d): directive \"%s\" takes %d parameters";
+
+	/* duplicate the buffer */
+	buf = (char *) malloc(strlen(readbuf) + 1);
+	if (!buf)
+	    fatal_error("not enough memory");
 
-   /* duplicate the buffer */
-   buf = (char *) malloc (strlen (readbuf) + 1);
-   if (! buf)
-      fatal_error ("not enough memory");
-   
-   /* break the line into whitespace-separated tokens.
-      whitespace can be enclosed in double quotes. */
-   for (in_token = 0, quoted = 0, iptr = readbuf, optr = buf, ntoks = 0;
-    ; iptr++)
-      {
-      if (*iptr == '\n' || *iptr == '\0')
-	 {
-	 if (in_token)
-	   *optr = '\0';
-	 break;
-	 }
+	/* break the line into whitespace-separated tokens.
+	   whitespace can be enclosed in double quotes. */
+	for (in_token = 0, quoted = 0, iptr = readbuf, optr = buf, ntoks = 0;;
+	     iptr++)
+	{
+	    if (*iptr == '\n' || *iptr == '\0')
+	    {
+		if (in_token)
+		    *optr = '\0';
+		break;
+	    }
 
-      else if (*iptr == '"')
-	 quoted ^= 1;
+	    else if (*iptr == '"')
+		quoted ^= 1;
 
-      // "#" at the beginning of a token
-      else if (! in_token && ! quoted && *iptr == '#')
-         break;
+	    // "#" at the beginning of a token
+	    else if (!in_token && !quoted && *iptr == '#')
+		break;
 
-      // First character of token
-      else if (! in_token && (quoted || ! isspace (*iptr)))
-	 {
-         if (ntoks >= (int) (sizeof token / sizeof *token))
-            fatal_error ("%s(%d): more than %d tokens",
-               filename, lineno, sizeof token / sizeof *token);
-	 token[ntoks] = optr;
-	 ntoks++;
-	 in_token = 1;
-	 *optr++ = *iptr;
-	 }
+	    // First character of token
+	    else if (!in_token && (quoted || !isspace(*iptr)))
+	    {
+		if (ntoks >= (int) (sizeof token / sizeof *token))
+		    fatal_error("%s(%d): more than %d tokens",
+				filename, lineno,
+				sizeof token / sizeof *token);
+		token[ntoks] = optr;
+		ntoks++;
+		in_token = 1;
+		*optr++ = *iptr;
+	    }
 
-      // First space between two tokens
-      else if (in_token && ! quoted && isspace (*iptr))
-	 {
-	 *optr++ = '\0';
-	 in_token = 0;
-	 }
+	    // First space between two tokens
+	    else if (in_token && !quoted && isspace(*iptr))
+	    {
+		*optr++ = '\0';
+		in_token = 0;
+	    }
 
-      // Character in the middle of a token
-      else if (in_token)
-	 *optr++ = *iptr;
-      }
-   if (quoted)
-      fatal_error ("%s(%d): unmatched double quote", filename, lineno);
+	    // Character in the middle of a token
+	    else if (in_token)
+		*optr++ = *iptr;
+	}
+	if (quoted)
+	    fatal_error("%s(%d): unmatched double quote", filename, lineno);
 
-   /* process line */
-   if (ntoks == 0)
-      {
-      free (buf);
-      continue;
-      }
-   if (! strcmp (token[0], "ldt"))
-      {
-      ldtdef_t buf;
+	/* process line */
+	if (ntoks == 0)
+	{
+	    free(buf);
+	    continue;
+	}
+	if (!strcmp(token[0], "ldt"))
+	{
+	    ldtdef_t buf;
 
-      if (ntoks != 5)
-	 fatal_error (bad_arg_count, filename, lineno, token[0], 4);
-      buf.number    = atoi (token[1]);
-      buf.ldtgroup  = *token[2];
-      buf.shortdesc = token[3];  /* FIXME: trunc to 16 char. */
-      buf.longdesc  = token[4];  /* FIXME: trunc reasonably */
-      if (al_lwrite (ldtdef, &buf))
-	 fatal_error ("LGD1 (%s)", al_astrerror (al_aerrno));
-      }
-   else if (! strcmp (token[0], "ldtgroup"))
-      {
-      ldtgroup_t buf;
+	    if (ntoks != 5)
+		fatal_error(bad_arg_count, filename, lineno, token[0], 4);
+	    buf.number = atoi(token[1]);
+	    buf.ldtgroup = *token[2];
+	    buf.shortdesc = token[3];	/* FIXME: trunc to 16 char. */
+	    buf.longdesc = token[4];	/* FIXME: trunc reasonably */
+	    if (al_lwrite(ldtdef, &buf))
+		fatal_error("LGD1 (%s)", al_astrerror(al_aerrno));
+	}
+	else if (!strcmp(token[0], "ldtgroup"))
+	{
+	    ldtgroup_t buf;
 
-      if (ntoks != 3)
-	 fatal_error (bad_arg_count, filename, lineno, token[0], 2);
-      buf.ldtgroup = *token[1];
-      buf.desc     = token[2];
-      if (al_lwrite (ldtgroup, &buf))
-	 fatal_error ("LGD2 (%s)", al_astrerror (al_aerrno));
-      }
-   else if (! strcmp (token[0], "level_format"))
-      {
-      if (ntoks != 2)
-	 fatal_error (bad_arg_count, filename, lineno, token[0], 1);
-      if (! strcmp (token[1], "alpha"))
-	 yg_level_format = YGLF_ALPHA;
-      else if (! strcmp (token[1], "doom"))
-         yg_level_format = YGLF_DOOM;
-      else if (! strcmp (token[1], "hexen"))
-         yg_level_format = YGLF_HEXEN;
-      else
-	 fatal_error ("%s(%d): invalid argument \"%.32s\" (alpha|doom|hexen)",
-            filename, lineno, token[1]);
-      free (buf);
-      }
-   else if (! strcmp (token[0], "level_name"))
-      {
-      if (ntoks != 2)
-	 fatal_error (bad_arg_count, filename, lineno, token[0], 1);
-      if (! strcmp (token[1], "e1m1"))
-         yg_level_name = YGLN_E1M1;
-      else if (! strcmp (token[1], "e1m10"))
-         yg_level_name = YGLN_E1M10;
-      else if (! strcmp (token[1], "map01"))
-         yg_level_name = YGLN_MAP01;
-      else
-	 fatal_error ("%s(%d): invalid argument \"%.32s\" (e1m1|e1m10|map01)",
-            filename, lineno, token[1]);
-      free (buf);
-      }
-   else if (! strcmp (token[0], "picture_format"))
-      {
-      if (ntoks != 2)
-         fatal_error (bad_arg_count, filename, lineno, token[0], 1);
-      if (! strcmp (token[1], "alpha"))
-	 yg_picture_format = YGPF_ALPHA;
-      else if (! strcmp (token[1], "pr"))
-	 yg_picture_format = YGPF_PR;
-      else if (! strcmp (token[1], "normal"))
-	 yg_picture_format = YGPF_NORMAL;
-      else
-	 fatal_error ("%s(%d): invalid argument \"%.32s\" (alpha|pr|normal)",
-	    filename, lineno, token[1]);
-      free (buf);
-      }
-   else if (! strcmp (token[0], "sky_flat"))
-      {
-      if (ntoks != 2)
-	 fatal_error (bad_arg_count, filename, lineno, token[0], 1);
-      sky_flat = token[1];
-      }
-   else if (! strcmp (token[0], "st"))
-      {
-      stdef_t buf;
+	    if (ntoks != 3)
+		fatal_error(bad_arg_count, filename, lineno, token[0], 2);
+	    buf.ldtgroup = *token[1];
+	    buf.desc = token[2];
+	    if (al_lwrite(ldtgroup, &buf))
+		fatal_error("LGD2 (%s)", al_astrerror(al_aerrno));
+	}
+	else if (!strcmp(token[0], "level_format"))
+	{
+	    if (ntoks != 2)
+		fatal_error(bad_arg_count, filename, lineno, token[0], 1);
+	    if (!strcmp(token[1], "alpha"))
+		yg_level_format = YGLF_ALPHA;
+	    else if (!strcmp(token[1], "doom"))
+		yg_level_format = YGLF_DOOM;
+	    else if (!strcmp(token[1], "hexen"))
+		yg_level_format = YGLF_HEXEN;
+	    else
+		fatal_error
+		    ("%s(%d): invalid argument \"%.32s\" (alpha|doom|hexen)",
+		     filename, lineno, token[1]);
+	    free(buf);
+	}
+	else if (!strcmp(token[0], "level_name"))
+	{
+	    if (ntoks != 2)
+		fatal_error(bad_arg_count, filename, lineno, token[0], 1);
+	    if (!strcmp(token[1], "e1m1"))
+		yg_level_name = YGLN_E1M1;
+	    else if (!strcmp(token[1], "e1m10"))
+		yg_level_name = YGLN_E1M10;
+	    else if (!strcmp(token[1], "map01"))
+		yg_level_name = YGLN_MAP01;
+	    else
+		fatal_error
+		    ("%s(%d): invalid argument \"%.32s\" (e1m1|e1m10|map01)",
+		     filename, lineno, token[1]);
+	    free(buf);
+	}
+	else if (!strcmp(token[0], "picture_format"))
+	{
+	    if (ntoks != 2)
+		fatal_error(bad_arg_count, filename, lineno, token[0], 1);
+	    if (!strcmp(token[1], "alpha"))
+		yg_picture_format = YGPF_ALPHA;
+	    else if (!strcmp(token[1], "pr"))
+		yg_picture_format = YGPF_PR;
+	    else if (!strcmp(token[1], "normal"))
+		yg_picture_format = YGPF_NORMAL;
+	    else
+		fatal_error
+		    ("%s(%d): invalid argument \"%.32s\" (alpha|pr|normal)",
+		     filename, lineno, token[1]);
+	    free(buf);
+	}
+	else if (!strcmp(token[0], "sky_flat"))
+	{
+	    if (ntoks != 2)
+		fatal_error(bad_arg_count, filename, lineno, token[0], 1);
+	    sky_flat = token[1];
+	}
+	else if (!strcmp(token[0], "st"))
+	{
+	    stdef_t buf;
 
-      if (ntoks != 4)
-	 fatal_error (bad_arg_count, filename, lineno, token[0], 3);
-      buf.number    = atoi (token[1]);
-      buf.shortdesc = token[2];  /* FIXME: trunc to 14 char. */
-      buf.longdesc  = token[3];  /* FIXME: trunc reasonably */
-      if (al_lwrite (stdef, &buf))
-	 fatal_error ("LGD3 (%s)", al_astrerror (al_aerrno));
-      }
-   else if (! strcmp (token[0], "texture_format"))
-      {
-      if (ntoks != 2)
-         fatal_error (bad_arg_count, filename, lineno, token[0], 1);
-      if (! strcmp (token[1], "nameless"))
-	 yg_texture_format = YGTF_NAMELESS;
-      else if (! strcmp (token[1], "normal"))
-	 yg_texture_format = YGTF_NORMAL;
-      else if (! strcmp (token[1], "strife11"))
-	 yg_texture_format = YGTF_STRIFE11;
-      else
-	 fatal_error (
-	    "%s(%d): invalid argument \"%.32s\" (normal|nameless|strife11)",
-	    filename, lineno, token[1]);
-      free (buf);
-      }
-   else if (! strcmp (token[0], "texture_lumps"))
-      {
-      if (ntoks != 2)
-         fatal_error (bad_arg_count, filename, lineno, token[0], 1);
-      if (! strcmp (token[1], "textures"))
-	 yg_texture_lumps = YGTL_TEXTURES;
-      else if (! strcmp (token[1], "normal"))
-	 yg_texture_lumps = YGTL_NORMAL;
-      else if (! strcmp (token[1], "none"))
-	 yg_texture_lumps = YGTL_NONE;
-      else
-	 fatal_error (
-	    "%s(%d): invalid argument \"%.32s\" (normal|textures|none)",
-	    filename, lineno, token[1]);
-      free (buf);
-      }
-   else if (! strcmp (token[0], "thing"))
-      {
-      thingdef_t buf;
+	    if (ntoks != 4)
+		fatal_error(bad_arg_count, filename, lineno, token[0], 3);
+	    buf.number = atoi(token[1]);
+	    buf.shortdesc = token[2];	/* FIXME: trunc to 14 char. */
+	    buf.longdesc = token[3];	/* FIXME: trunc reasonably */
+	    if (al_lwrite(stdef, &buf))
+		fatal_error("LGD3 (%s)", al_astrerror(al_aerrno));
+	}
+	else if (!strcmp(token[0], "texture_format"))
+	{
+	    if (ntoks != 2)
+		fatal_error(bad_arg_count, filename, lineno, token[0], 1);
+	    if (!strcmp(token[1], "nameless"))
+		yg_texture_format = YGTF_NAMELESS;
+	    else if (!strcmp(token[1], "normal"))
+		yg_texture_format = YGTF_NORMAL;
+	    else if (!strcmp(token[1], "strife11"))
+		yg_texture_format = YGTF_STRIFE11;
+	    else
+		fatal_error
+		    ("%s(%d): invalid argument \"%.32s\" (normal|nameless|strife11)",
+		     filename, lineno, token[1]);
+	    free(buf);
+	}
+	else if (!strcmp(token[0], "texture_lumps"))
+	{
+	    if (ntoks != 2)
+		fatal_error(bad_arg_count, filename, lineno, token[0], 1);
+	    if (!strcmp(token[1], "textures"))
+		yg_texture_lumps = YGTL_TEXTURES;
+	    else if (!strcmp(token[1], "normal"))
+		yg_texture_lumps = YGTL_NORMAL;
+	    else if (!strcmp(token[1], "none"))
+		yg_texture_lumps = YGTL_NONE;
+	    else
+		fatal_error
+		    ("%s(%d): invalid argument \"%.32s\" (normal|textures|none)",
+		     filename, lineno, token[1]);
+	    free(buf);
+	}
+	else if (!strcmp(token[0], "thing"))
+	{
+	    thingdef_t buf;
 
-      if (ntoks < 6 || ntoks > 7)
-	 fatal_error (
-            "%s(d%): directive \"%s\" takes between 5 and 6 parameters",
-            filename, lineno, token[0]);
-      buf.number     = atoi (token[1]);
-      buf.thinggroup = *token[2];
-      buf.flags      = *token[3] == 's' ? THINGDEF_SPECTRAL : 0;  // FIXME!
-      buf.radius     = atoi (token[4]);
-      buf.desc       = token[5];
-      buf.sprite     = ntoks >= 7 ? token[6] : 0;
-      if (al_lwrite (thingdef, &buf))
-	 fatal_error ("LGD4 (%s)", al_astrerror (al_aerrno));
-      }
-   else if (! strcmp (token[0], "thinggroup"))
-      {
-      thinggroup_t buf;
+	    if (ntoks < 6 || ntoks > 7)
+		fatal_error
+		    ("%s(d%): directive \"%s\" takes between 5 and 6 parameters",
+		     filename, lineno, token[0]);
+	    buf.number = atoi(token[1]);
+	    buf.thinggroup = *token[2];
+	    buf.flags = *token[3] == 's' ? THINGDEF_SPECTRAL : 0;	// FIXME!
+	    buf.radius = atoi(token[4]);
+	    buf.desc = token[5];
+	    buf.sprite = ntoks >= 7 ? token[6] : 0;
+	    if (al_lwrite(thingdef, &buf))
+		fatal_error("LGD4 (%s)", al_astrerror(al_aerrno));
+	}
+	else if (!strcmp(token[0], "thinggroup"))
+	{
+	    thinggroup_t buf;
 
-      if (ntoks != 4)
-	 fatal_error (bad_arg_count, filename, lineno, token[0], 3);
-      buf.thinggroup = *token[1];
-      if (getcolour (token[2], &buf.rgb))
-	 fatal_error ("%s(%d): bad colour spec \"%.32s\"",
-            filename, lineno, token[2]);
-      buf.acn = add_app_colour (buf.rgb);
-      buf.desc = token[3];
-      if (al_lwrite (thinggroup, &buf))
-	 fatal_error ("LGD5 (%s)", al_astrerror (al_aerrno));
-      }
-   else
-      {
-      free (buf);
-      fatal_error ("%s(%d): unknown directive \"%.32s\"",
-	 filename, lineno, token[0]);
-      }
-   }
+	    if (ntoks != 4)
+		fatal_error(bad_arg_count, filename, lineno, token[0], 3);
+	    buf.thinggroup = *token[1];
+	    if (getcolour(token[2], &buf.rgb))
+		fatal_error("%s(%d): bad colour spec \"%.32s\"",
+			    filename, lineno, token[2]);
+	    buf.acn = add_app_colour(buf.rgb);
+	    buf.desc = token[3];
+	    if (al_lwrite(thinggroup, &buf))
+		fatal_error("LGD5 (%s)", al_astrerror(al_aerrno));
+	}
+	else
+	{
+	    free(buf);
+	    fatal_error("%s(%d): unknown directive \"%.32s\"",
+			filename, lineno, token[0]);
+	}
+    }
 
-fclose (ygdfile);
+    fclose(ygdfile);
 
 /* Verify that all the mandatory directives are present. */
-{
-bool abort = false;
-if (yg_level_format == YGLF__)
-   {
-   err ("%s: Missing \"level_format\" directive.", filename);
-   abort = true;
-   }
-if (yg_level_name == YGLN__)
-   {
-   err ("%s: Missing \"level_name\" directive.", filename);
-   abort = true;
-   }
+    {
+	bool abort = false;
+	if (yg_level_format == YGLF__)
+	{
+	    err("%s: Missing \"level_format\" directive.", filename);
+	    abort = true;
+	}
+	if (yg_level_name == YGLN__)
+	{
+	    err("%s: Missing \"level_name\" directive.", filename);
+	    abort = true;
+	}
 // FIXME perhaps print a warning message if picture_format
 // is missing ("assuming picture_format=normal").
 // FIXME and same thing for texture_format and texture_lumps ?
-if (abort)
-   exit (2);
-}
+	if (abort)
+	    exit(2);
+    }
 
 #if 0
 
@@ -361,44 +365,44 @@
 
 /* Speed optimization : build the table of things attributes
    that get_thing_*() use. */
-create_things_table ();
+    create_things_table();
 
 /* KLUDGE: Add bogus ldtgroup LDT_FREE. InputLinedefType()
    knows that it means "let the user enter a number". */
-{
-ldtgroup_t buf;
+    {
+	ldtgroup_t buf;
 
-buf.ldtgroup = LDT_FREE;  /* that is '\0' */
-buf.desc     = "Other (enter number)";
-al_lseek (ldtgroup, 0, SEEK_END);
-if (al_lwrite (ldtgroup, &buf))
-  fatal_error ("LGD90 (%s)", al_astrerror (al_aerrno));
-}
+	buf.ldtgroup = LDT_FREE;	/* that is '\0' */
+	buf.desc = "Other (enter number)";
+	al_lseek(ldtgroup, 0, SEEK_END);
+	if (al_lwrite(ldtgroup, &buf))
+	    fatal_error("LGD90 (%s)", al_astrerror(al_aerrno));
+    }
 
 /* KLUDGE: Add bogus thinggroup THING_FREE.
    InputThingType() knows that it means "let the user enter a number". */
-{
-thinggroup_t buf;
+    {
+	thinggroup_t buf;
 
-buf.thinggroup = THING_FREE;  /* that is '\0' */
-buf.desc       = "Other (enter number)";
-al_lseek (thinggroup, 0, SEEK_END);
-if (al_lwrite (thinggroup, &buf))
-  fatal_error ("LGD91 (%s)", al_astrerror (al_aerrno));
-}
+	buf.thinggroup = THING_FREE;	/* that is '\0' */
+	buf.desc = "Other (enter number)";
+	al_lseek(thinggroup, 0, SEEK_END);
+	if (al_lwrite(thinggroup, &buf))
+	    fatal_error("LGD91 (%s)", al_astrerror(al_aerrno));
+    }
 
 /* KLUDGE: Add bogus sector type at the end of stdef.
    SectorProperties() knows that it means "let the user enter a number". */
-{
-stdef_t buf;
+    {
+	stdef_t buf;
 
-buf.number    = 0;     /* not significant */
-buf.shortdesc = 0;     /* not significant */
-buf.longdesc  = "Other (enter number)";
-al_lseek (stdef, 0, SEEK_END);
-if (al_lwrite (stdef, &buf))
-  fatal_error ("LGD92 (%s)", al_astrerror (al_aerrno));
-}
+	buf.number = 0;		/* not significant */
+	buf.shortdesc = 0;	/* not significant */
+	buf.longdesc = "Other (enter number)";
+	al_lseek(stdef, 0, SEEK_END);
+	if (al_lwrite(stdef, &buf))
+	    fatal_error("LGD92 (%s)", al_astrerror(al_aerrno));
+    }
 
 }
 
@@ -407,14 +411,12 @@
  *	FreeGameDefs
  *	Free all memory allocated to game definitions
  */
-void FreeGameDefs (void)
+void FreeGameDefs(void)
 {
-delete_things_table ();
-al_ldiscard (ldtdef    );
-al_ldiscard (ldtgroup  );
-al_ldiscard (stdef     );
-al_ldiscard (thingdef  );
-al_ldiscard (thinggroup);
+    delete_things_table();
+    al_ldiscard(ldtdef);
+    al_ldiscard(ldtgroup);
+    al_ldiscard(stdef);
+    al_ldiscard(thingdef);
+    al_ldiscard(thinggroup);
 }
-
-
--- a/src/game.h	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/game.h	Sat Sep 24 14:16:04 2011 +0300
@@ -17,50 +17,50 @@
 
 // ldt <number> <ldtgroup> <shortdesc> <longdesc>
 typedef struct
-   {
-   int number;
-   char ldtgroup;
-   const char *shortdesc;
-   const char *longdesc;
-   } ldtdef_t;
+{
+    int number;
+    char ldtgroup;
+    const char *shortdesc;
+    const char *longdesc;
+} ldtdef_t;
 
 // ldtgroup <ldtgroup> <description>
 typedef struct
-   {
-   char ldtgroup;
-   const char *desc;
-   } ldtgroup_t;
+{
+    char ldtgroup;
+    const char *desc;
+} ldtgroup_t;
 
 // st <number> <shortdesc> <longdesc>
 typedef struct
-   {
-   int number;
-   const char *shortdesc;
-   const char *longdesc;
-   } stdef_t;
+{
+    int number;
+    const char *shortdesc;
+    const char *longdesc;
+} stdef_t;
 
 // thing <number> <thinggroup> <flags> <radius> <description> [<sprite>]
 typedef struct
-   {
-   int number;		// Thing number
-   char thinggroup;	// Thing group
-   char flags;		// Flags
-   int radius;		// Radius of thing
-   const char *desc;	// Short description of thing
-   const char *sprite;  // Root of name of sprite for thing
-   } thingdef_t;
+{
+    int number;			// Thing number
+    char thinggroup;		// Thing group
+    char flags;			// Flags
+    int radius;			// Radius of thing
+    const char *desc;		// Short description of thing
+    const char *sprite;		// Root of name of sprite for thing
+} thingdef_t;
 /* (1)  This is only here for speed, to avoid having to lookup
         thinggroup for each thing when drawing things */
 const char THINGDEF_SPECTRAL = 0x01;
 
 // thinggroup <thinggroup> <colour> <description>
 typedef struct
-   {
-   char thinggroup;	// Thing group
-   rgb_c rgb;		// RGB colour
-   acolour_t acn;	// Application colour#
-   const char *desc;	// Description of thing group
-   } thinggroup_t;
+{
+    char thinggroup;		// Thing group
+    rgb_c rgb;			// RGB colour
+    acolour_t acn;		// Application colour#
+    const char *desc;		// Description of thing group
+} thinggroup_t;
 
 
 /*
@@ -68,8 +68,10 @@
  *	Those variables are defined in yadex.cc
  */
 
-typedef enum { YGLF__, YGLF_ALPHA, YGLF_DOOM, YGLF_HEXEN } yglf_t;
-typedef enum { YGLN__, YGLN_E1M10, YGLN_E1M1, YGLN_MAP01 } ygln_t;
+typedef enum
+{ YGLF__, YGLF_ALPHA, YGLF_DOOM, YGLF_HEXEN } yglf_t;
+typedef enum
+{ YGLN__, YGLN_E1M10, YGLN_E1M1, YGLN_MAP01 } ygln_t;
 // ygpf_t and ygtf_t are defined in yadex.h
 extern yglf_t yg_level_format;
 extern ygln_t yg_level_name;
@@ -90,8 +92,6 @@
 #define CUR_THINGDEF   ((thingdef_t   *)al_lptr (thingdef  ))
 #define CUR_THINGGROUP ((thinggroup_t *)al_lptr (thinggroup))
 
-#define LDT_FREE    '\0'  /* KLUDGE: bogus ldt group   (see game.c) */
-#define ST_FREE     '\0'  /* KLUDGE: bogus sector type (see game.c) */
-#define THING_FREE  '\0'  /* KLUDGE: bogus thing group (see game.c) */
-
-
+#define LDT_FREE    '\0'	/* KLUDGE: bogus ldt group   (see game.c) */
+#define ST_FREE     '\0'	/* KLUDGE: bogus sector type (see game.c) */
+#define THING_FREE  '\0'	/* KLUDGE: bogus thing group (see game.c) */
--- a/src/gamedef.h	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/gamedef.h	Sat Sep 24 14:16:04 2011 +0300
@@ -4,7 +4,7 @@
  */
 
 
-#ifndef YH_GAMEDEF  /* DO NOT INSERT ANYTHING BEFORE THIS LINE */
+#ifndef YH_GAMEDEF		/* DO NOT INSERT ANYTHING BEFORE THIS LINE */
 #define YH_GAMEDEF
 
 
@@ -13,9 +13,9 @@
 
 typedef struct
 {
-  char ldtgroup;
-  const char *shortdesc;
-  const char *longdesc;
+    char ldtgroup;
+    const char *shortdesc;
+    const char *longdesc;
 } linedef_type_t;
 
 
@@ -24,14 +24,14 @@
 
 typedef struct
 {
-  const char *desc;
+    const char *desc;
 } linedef_type_group_t;
 
 
 typedef struct
 {
-  const char *shortdesc;
-  const char *longdesc;
+    const char *shortdesc;
+    const char *longdesc;
 } sector_type_t;
 
 
@@ -40,10 +40,10 @@
 
 typedef struct
 {
-  char flags;		// Flags
-  int radius;		// Radius of thing
-  const char *desc;	// Short description of thing
-  const char *sprite;	// Root of name of sprite for thing
+    char flags;			// Flags
+    int radius;			// Radius of thing
+    const char *desc;		// Short description of thing
+    const char *sprite;		// Root of name of sprite for thing
 } thing_type_t;
 
 
@@ -52,25 +52,30 @@
 
 typedef struct
 {
-  char thinggroup;	// Thing group
-  rgb_c rgb;		// RGB colour
-  acolour_t acn;	// Application colour#
-  const char *desc;	// Description of thing group
+    char thinggroup;		// Thing group
+    rgb_c rgb;			// RGB colour
+    acolour_t acn;		// Application colour#
+    const char *desc;		// Description of thing group
 } thing_type_group_t;
 
 
-typedef enum { YGLF__, YGLF_ALPHA, YGLF_DOOM, YGLF_HEXEN } yglf_t;
-typedef enum { YGLN__, YGLN_E1M10, YGLN_E1M1, YGLN_MAP01 } ygln_t;
-typedef enum { YGPF_NORMAL, YGPF_ALPHA, YGPF_PR } ygpf_t;
-typedef enum { YGTF_NORMAL, YGTF_NAMELESS, YGTF_STRIFE11 } ygtf_t;
-typedef enum { YGTL_NORMAL, YGTL_TEXTURES, YGTL_NONE } ygtl_t;
+typedef enum
+{ YGLF__, YGLF_ALPHA, YGLF_DOOM, YGLF_HEXEN } yglf_t;
+typedef enum
+{ YGLN__, YGLN_E1M10, YGLN_E1M1, YGLN_MAP01 } ygln_t;
+typedef enum
+{ YGPF_NORMAL, YGPF_ALPHA, YGPF_PR } ygpf_t;
+typedef enum
+{ YGTF_NORMAL, YGTF_NAMELESS, YGTF_STRIFE11 } ygtf_t;
+typedef enum
+{ YGTL_NORMAL, YGTL_TEXTURES, YGTL_NONE } ygtl_t;
 
 
 /* shorthands to make program more readable */
 
-#define LDT_FREE    '\0'  /* KLUDGE: bogus ldt group   (see game.c) */
-#define ST_FREE     '\0'  /* KLUDGE: bogus sector type (see game.c) */
-#define THING_FREE  '\0'  /* KLUDGE: bogus thing group (see game.c) */
+#define LDT_FREE    '\0'	/* KLUDGE: bogus ldt group   (see game.c) */
+#define ST_FREE     '\0'	/* KLUDGE: bogus sector type (see game.c) */
+#define THING_FREE  '\0'	/* KLUDGE: bogus thing group (see game.c) */
 
 
 /*
@@ -78,34 +83,32 @@
  */
 class Game_def
 {
-  public :
-    Game_def ();
-    ~Game_def ();
-    const linedef_type_t& linedef_type (wad_ldtype_t type) const;
-    const sector_type_t&  sector_type  (wad_stype_t  type) const;
-    const thing_type_t&   thing_type   (wad_ttype_t  type) const;
-    void linedef_type     (wad_ldtype_t type, linedef_type_t& data);
-    void sector_type      (wad_stype_t type,  sector_type_t&  data);
-    void thing_type       (wad_ttype_t type,  thing_type_t&   data);
-    void del_linedef_type (wad_ldtype_t type);
-    void del_sector_type  (wad_stype_t  type);
-    void del_thing_type   (wad_ttype_t  type);
-    int level_format      (yglf_t level_format);
-    int level_name        (yglf_t level_name);
-    int picture_format    (ygpf_t picture_format);
-    int texture_format    (ygtf_t texture_format);
-    int texture_lumps     (ygtl_t texture_lumps);
-    yglf_t level_format   () const;
-    ygln_t level_name     () const;
-    ygpf_t picture_format () const;
-    ygtf_t texture_format () const;
-    ygtl_t texture_lumps  () const;
+    public:Game_def();
+    ~Game_def();
+    const linedef_type_t & linedef_type(wad_ldtype_t type) const;
+    const sector_type_t & sector_type(wad_stype_t type) const;
+    const thing_type_t & thing_type(wad_ttype_t type) const;
+    void linedef_type(wad_ldtype_t type, linedef_type_t & data);
+    void sector_type(wad_stype_t type, sector_type_t & data);
+    void thing_type(wad_ttype_t type, thing_type_t & data);
+    void del_linedef_type(wad_ldtype_t type);
+    void del_sector_type(wad_stype_t type);
+    void del_thing_type(wad_ttype_t type);
+    int level_format(yglf_t level_format);
+    int level_name(yglf_t level_name);
+    int picture_format(ygpf_t picture_format);
+    int texture_format(ygtf_t texture_format);
+    int texture_lumps(ygtl_t texture_lumps);
+    yglf_t level_format() const;
+    ygln_t level_name() const;
+    ygpf_t picture_format() const;
+    ygtf_t texture_format() const;
+    ygtl_t texture_lumps() const;
 
-  private :
-    Game_def            (const Game_def&);	// Too lazy to implement it
-    Game_def& operator= (const Game_def&);	// Too lazy to implement it
+      private: Game_def(const Game_def &);	// Too lazy to implement it
+      Game_def & operator=(const Game_def &);	// Too lazy to implement it
     Game_def_priv *priv;
 };
 
 
-#endif  /* DO NOT ADD ANYTHING AFTER THIS LINE */
+#endif /* DO NOT ADD ANYTHING AFTER THIS LINE */
--- a/src/gamesky.h	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/gamesky.h	Sat Sep 24 14:16:04 2011 +0300
@@ -4,7 +4,7 @@
  */
 
 
-#ifndef YH_GAMESKY  /* DO NOT INSERT ANYTHING BEFORE THIS LINE */
+#ifndef YH_GAMESKY		/* DO NOT INSERT ANYTHING BEFORE THIS LINE */
 #define YH_GAMESKY
 
 
@@ -17,10 +17,10 @@
 /*
  *	is_sky - is this flat a sky
  */
-inline bool is_sky (const char *flat)
+inline bool is_sky(const char *flat)
 {
-  return sky_flat == flat;
+    return sky_flat == flat;
 }
 
 
-#endif  /* DO NOT ADD ANYTHING AFTER THIS LINE */
+#endif /* DO NOT ADD ANYTHING AFTER THIS LINE */
--- a/src/gcolour1.cc	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/gcolour1.cc	Sat Sep 24 14:16:04 2011 +0300
@@ -41,7 +41,7 @@
 #include "gcolour1.h"
 #include "gcolour2.h"
 #include "gfx.h"
-#include "img.h"	/* IMG_TRANSP */
+#include "img.h"		/* IMG_TRANSP */
 #include "rgb.h"
 #include "wadfile.h"
 #include "wads.h"
@@ -53,100 +53,101 @@
  *	Put the DOOM_COLOURS physical colour numbers corresponding
  *	to the game colours in the <game_colour> array.
  */
-pcolour_t *alloc_game_colours (int playpalnum)
+pcolour_t *alloc_game_colours(int playpalnum)
 {
-MDirPtr dir;
-u8	*dpal;
-pcolour_t *game_colours = 0;
+    MDirPtr dir;
+    u8 *dpal;
+    pcolour_t *game_colours = 0;
 
-dir = FindMasterDir (MasterDir, "PLAYPAL");
-if (dir == NULL)
-   {
-   warn ("PLAYPAL lump not found.\n");
-   return 0;
-   }
+    dir = FindMasterDir(MasterDir, "PLAYPAL");
+    if (dir == NULL)
+    {
+	warn("PLAYPAL lump not found.\n");
+	return 0;
+    }
 
-int playpal_count = dir->dir.size / (3 * DOOM_COLOURS);
-if (playpalnum < 0 || playpalnum >= playpal_count)
-   {
-   warn ("playpalnum %d out of range (0-%d). Using #0 instead.\n",
-      playpalnum, playpal_count - 1);
-   playpalnum = 0;
-   }
+    int playpal_count = dir->dir.size / (3 * DOOM_COLOURS);
+    if (playpalnum < 0 || playpalnum >= playpal_count)
+    {
+	warn("playpalnum %d out of range (0-%d). Using #0 instead.\n",
+	     playpalnum, playpal_count - 1);
+	playpalnum = 0;
+    }
 
-dpal = (u8 *) GetMemory (3 * DOOM_COLOURS);
-dir->wadfile->seek (dir->dir.start);
-if (dir->wadfile->error ())
-   {
-   warn ("%s: can't seek to %lXh\n",
-       dir->wadfile->pathname (), (unsigned long) dir->dir.start);
-   warn ("PLAYPAL: seek error\n");
-   }
-for (int n = 0; n <= playpalnum; n++)
-   {
-   dir->wadfile->read_bytes (dpal, 3 * DOOM_COLOURS);
-   if (dir->wadfile->error ())
-      {
-      warn ("%s: read error\n", dir->wadfile->where ());
-      warn ("PLAYPAL: error reading entry #%d\n", n);
-      }
-   }
+    dpal = (u8 *) GetMemory(3 * DOOM_COLOURS);
+    dir->wadfile->seek(dir->dir.start);
+    if (dir->wadfile->error())
+    {
+	warn("%s: can't seek to %lXh\n",
+	     dir->wadfile->pathname(), (unsigned long) dir->dir.start);
+	warn("PLAYPAL: seek error\n");
+    }
+    for (int n = 0; n <= playpalnum; n++)
+    {
+	dir->wadfile->read_bytes(dpal, 3 * DOOM_COLOURS);
+	if (dir->wadfile->error())
+	{
+	    warn("%s: read error\n", dir->wadfile->where());
+	    warn("PLAYPAL: error reading entry #%d\n", n);
+	}
+    }
 #if defined Y_BGI
-for (int n = 0; n < 3 * DOOM_COLOURS; n++)
-   dpal[n] /= 4;
-_AX = 0x1012;
-_BX = 0;
-_CX = DOOM_COLOURS;
-_ES = FP_SEG (dpal);
-_DX = FP_OFF (dpal);
-__int__ (0x10);
+    for (int n = 0; n < 3 * DOOM_COLOURS; n++)
+	dpal[n] /= 4;
+    _AX = 0x1012;
+    _BX = 0;
+    _CX = DOOM_COLOURS;
+    _ES = FP_SEG(dpal);
+    _DX = FP_OFF(dpal);
+    __int__(0x10);
 #elif defined Y_X11
 
-rgb_c rgb_values[DOOM_COLOURS];
-for (size_t n = 0; n < DOOM_COLOURS; n++)
-   {
-   rgb_values[n].r = (u8) dpal[3 * n];
-   rgb_values[n].g = (u8) dpal[3 * n + 1];
-   rgb_values[n].b = (u8) dpal[3 * n + 2];
-   }
-game_colours = alloc_colours (rgb_values, DOOM_COLOURS);
+    rgb_c rgb_values[DOOM_COLOURS];
+    for (size_t n = 0; n < DOOM_COLOURS; n++)
+    {
+	rgb_values[n].r = (u8) dpal[3 * n];
+	rgb_values[n].g = (u8) dpal[3 * n + 1];
+	rgb_values[n].b = (u8) dpal[3 * n + 2];
+    }
+    game_colours = alloc_colours(rgb_values, DOOM_COLOURS);
 
 // Find the colour closest to IMG_TRANSP
-{
-  colour0 = IMG_TRANSP;
-  int smallest_delta = INT_MAX;
+    {
+	colour0 = IMG_TRANSP;
+	int smallest_delta = INT_MAX;
+
+	for (size_t n = 1; n < DOOM_COLOURS; n++)
+	{
+	    int delta = rgb_values[IMG_TRANSP] - rgb_values[n];
+	    if (delta < smallest_delta)
+	    {
+		colour0 = n;
+		smallest_delta = delta;
+	    }
+	}
+	verbmsg("colours: colour %d remapped to %d (delta %d)\n",
+		IMG_TRANSP, colour0, smallest_delta);
 
-  for (size_t n = 1; n < DOOM_COLOURS; n++)
-  {
-    int delta = rgb_values[IMG_TRANSP] - rgb_values[n];
-    if (delta < smallest_delta)
-    {
-      colour0 = n;
-      smallest_delta = delta;
+	rgb_c med_blue(0, 0, 128);
+	sky_colour = 0;
+	smallest_delta = INT_MAX;
+
+	for (size_t n = 0; n < DOOM_COLOURS; n++)
+	{
+	    int delta = med_blue - rgb_values[n];
+	    if (delta < smallest_delta)
+	    {
+		sky_colour = n;
+		smallest_delta = delta;
+	    }
+	}
+	verbmsg("Sky Colour remapped to %d (delta %d)\n", sky_colour,
+		smallest_delta);
     }
-  }
-  verbmsg ("colours: colour %d remapped to %d (delta %d)\n",
-    IMG_TRANSP, colour0, smallest_delta);
-   
-   rgb_c med_blue (0, 0, 128);
-   sky_colour = 0;
-   smallest_delta = INT_MAX;
- 
-   for (size_t n = 0; n < DOOM_COLOURS; n++)
-   {
-     int delta = med_blue - rgb_values[n];
-     if (delta < smallest_delta)
-     {
-       sky_colour = n;
-       smallest_delta = delta;
-     }
-   }
-   verbmsg ("Sky Colour remapped to %d (delta %d)\n", sky_colour, smallest_delta);
-}
 
 #endif
-FreeMemory (dpal);
-return game_colours;
+    FreeMemory(dpal);
+    return game_colours;
 }
 
 
@@ -154,9 +155,9 @@
  *	free_game_colours
  *	Free the game colours allocated by alloc_game_colours()
  */
-void free_game_colours (pcolour_t *game_colours)
+void free_game_colours(pcolour_t * game_colours)
 {
-free_colours (game_colours, DOOM_COLOURS);
+    free_colours(game_colours, DOOM_COLOURS);
 }
 
 
@@ -168,41 +169,41 @@
 #if 0
 /* FIXME this is a gross hack */
 for (n = 0; n < DOOM_COLOURS; n++)
-   {
-   xpv_t r = dpal[3*n];
-   xpv_t g = dpal[3*n+1];
-   xpv_t b = dpal[3*n+2];
-   if (win_vis_class == DirectColor || win_vis_class == TrueColor)
-      {
-      xpv_t r_scaled, g_scaled, b_scaled;
-      if (win_r_ofs + win_r_bits < 8)
-	 r_scaled = r >> (8 - (win_r_ofs + win_r_bits));
-      else
-	 r_scaled = r << (win_r_ofs + win_r_bits - 8) & win_r_mask;
-      if (win_g_ofs + win_g_bits < 8)
-	 g_scaled = g >> (8 - (win_g_ofs + win_g_bits));
-      else
-	 g_scaled = g << (win_g_ofs + win_g_bits - 8) & win_g_mask;
-      if (win_b_ofs + win_b_bits < 8)
-	 b_scaled = b >> (8 - (win_b_ofs + win_b_bits));
-      else
-	 b_scaled = b << (win_b_ofs + win_b_bits - 8) & win_b_mask;
-      game_colour[n] = r_scaled | g_scaled | b_scaled;
-      }
-   else if (win_vis_class== PseudoColor || win_vis_class == StaticColor)
-      game_colour[n] = n;  /* Ugh! */
-   else if (win_vis_class == GrayScale || win_vis_class == StaticGray)
-      {
-      game_colour[n] = (r + g + b) / 3;
-      if (win_depth < 8)
-	 game_colour[n] >>= 8 - win_depth;
-      else
-	 game_colour[n] <<= win_depth - 8;
-      }
-   // printf ("%02X %08lX", n, (unsigned long) game_colour[n]);
-   // if (n % 6 == 5)
-   //    putchar ('\n');
-   // else
-   //    printf ("  ");
-   }
-#endif  /* #if 0 */
+{
+    xpv_t r = dpal[3 * n];
+    xpv_t g = dpal[3 * n + 1];
+    xpv_t b = dpal[3 * n + 2];
+    if (win_vis_class == DirectColor || win_vis_class == TrueColor)
+    {
+	xpv_t r_scaled, g_scaled, b_scaled;
+	if (win_r_ofs + win_r_bits < 8)
+	    r_scaled = r >> (8 - (win_r_ofs + win_r_bits));
+	else
+	    r_scaled = r << (win_r_ofs + win_r_bits - 8) & win_r_mask;
+	if (win_g_ofs + win_g_bits < 8)
+	    g_scaled = g >> (8 - (win_g_ofs + win_g_bits));
+	else
+	    g_scaled = g << (win_g_ofs + win_g_bits - 8) & win_g_mask;
+	if (win_b_ofs + win_b_bits < 8)
+	    b_scaled = b >> (8 - (win_b_ofs + win_b_bits));
+	else
+	    b_scaled = b << (win_b_ofs + win_b_bits - 8) & win_b_mask;
+	game_colour[n] = r_scaled | g_scaled | b_scaled;
+    }
+    else if (win_vis_class == PseudoColor || win_vis_class == StaticColor)
+	game_colour[n] = n;	/* Ugh! */
+    else if (win_vis_class == GrayScale || win_vis_class == StaticGray)
+    {
+	game_colour[n] = (r + g + b) / 3;
+	if (win_depth < 8)
+	    game_colour[n] >>= 8 - win_depth;
+	else
+	    game_colour[n] <<= win_depth - 8;
+    }
+    // printf ("%02X %08lX", n, (unsigned long) game_colour[n]);
+    // if (n % 6 == 5)
+    //    putchar ('\n');
+    // else
+    //    printf ("  ");
+}
+#endif /* #if 0 */
--- a/src/gcolour1.h	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/gcolour1.h	Sat Sep 24 14:16:04 2011 +0300
@@ -17,6 +17,5 @@
 #include "colour.h"
 
 
-pcolour_t *alloc_game_colours (int playpalnum);
-void free_game_colours (pcolour_t *game_colours);
-
+pcolour_t *alloc_game_colours(int playpalnum);
+void free_game_colours(pcolour_t * game_colours);
--- a/src/gcolour2.cc	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/gcolour2.cc	Sat Sep 24 14:16:04 2011 +0300
@@ -36,4 +36,3 @@
 pcolour_t *game_colour = 0;	// Pixel values for the DOOM_COLOURS game clrs.
 int colour0;			// Game colour to which g. colour 0 is remapped
 int sky_colour;			// Game colour for a medium sky blue
-
--- a/src/gcolour2.h	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/gcolour2.h	Sat Sep 24 14:16:04 2011 +0300
@@ -8,7 +8,6 @@
 #include "colour.h"
 
 
-extern pcolour_t *game_colour;  // Pixel values for the DOOM_COLOURS game clrs.
+extern pcolour_t *game_colour;	// Pixel values for the DOOM_COLOURS game clrs.
 extern int colour0;		// Game colour to which g. colour 0 is remapped
 extern int sky_colour;		// Game colour for a medium blue sky
-
--- a/src/gcolour3.cc	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/gcolour3.cc	Sat Sep 24 14:16:04 2011 +0300
@@ -35,28 +35,27 @@
 Game_colour_24 game_colour_24;
 
 
-void Game_colour_24::refresh (const pcolour_t *game_colour, bool big_endian)
+void Game_colour_24::refresh(const pcolour_t * game_colour, bool big_endian)
 {
-  if (pv_table == 0)
-    pv_table = new pv24_t[DOOM_COLOURS];
+    if (pv_table == 0)
+	pv_table = new pv24_t[DOOM_COLOURS];
 
-  if (big_endian)
-  {
-    for (size_t n = 0; n < DOOM_COLOURS; n++)
+    if (big_endian)
     {
-      pv_table[n][0] = game_colour[n] / 0x10000;
-      pv_table[n][1] = game_colour[n] / 0x100;
-      pv_table[n][2] = game_colour[n];
+	for (size_t n = 0; n < DOOM_COLOURS; n++)
+	{
+	    pv_table[n][0] = game_colour[n] / 0x10000;
+	    pv_table[n][1] = game_colour[n] / 0x100;
+	    pv_table[n][2] = game_colour[n];
+	}
     }
-  }
-  else
-  {
-    for (size_t n = 0; n < DOOM_COLOURS; n++)
+    else
     {
-      pv_table[n][0] = game_colour[n];
-      pv_table[n][1] = game_colour[n] / 0x100;
-      pv_table[n][2] = game_colour[n] / 0x10000;
+	for (size_t n = 0; n < DOOM_COLOURS; n++)
+	{
+	    pv_table[n][0] = game_colour[n];
+	    pv_table[n][1] = game_colour[n] / 0x100;
+	    pv_table[n][2] = game_colour[n] / 0x10000;
+	}
     }
-  }
 }
-
--- a/src/gcolour3.h	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/gcolour3.h	Sat Sep 24 14:16:04 2011 +0300
@@ -27,7 +27,7 @@
 */
 
 
-#ifndef YH_GCOLOUR3  /* DO NOT INSERT ANYTHING BEFORE THIS LINE */
+#ifndef YH_GCOLOUR3		/* DO NOT INSERT ANYTHING BEFORE THIS LINE */
 #define YH_GCOLOUR3
 
 
@@ -56,24 +56,33 @@
  */
 
 
-typedef u8 pv24_t[3];  // A 24-bit pixel value
+typedef u8 pv24_t[3];		// A 24-bit pixel value
 
 
 class Game_colour_24
 {
-  public :
-    Game_colour_24 () { pv_table = 0; }
-    ~Game_colour_24 () { if (pv_table) delete[] pv_table; }
+    public: Game_colour_24()
+    {
+	pv_table = 0;
+    }
+     ~Game_colour_24()
+    {
+	if (pv_table)
+	    delete[]pv_table;
+    }
     // Create/refresh the table
-    void refresh (const pcolour_t *game_colour, const bool big_endian);
+    void refresh(const pcolour_t * game_colour, const bool big_endian);
     // Return a pointer on an array of pv24_t[DOOM_COLOURS]
-    const pv24_t *lut () { return pv_table; }
-  private :
-    pv24_t *pv_table;
+    const pv24_t *lut()
+    {
+	return pv_table;
+    }
+  private:
+    pv24_t * pv_table;
 };
 
 
 extern Game_colour_24 game_colour_24;
 
 
-#endif  /* DO NOT ADD ANYTHING AFTER THIS LINE */
+#endif /* DO NOT ADD ANYTHING AFTER THIS LINE */
--- a/src/geom.cc	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/geom.cc	Sat Sep 24 14:16:04 2011 +0300
@@ -36,9 +36,9 @@
    translate (dx, dy) into an integer angle value (0-65535)
 */
 
-unsigned ComputeAngle (int dx, int dy)
+unsigned ComputeAngle(int dx, int dy)
 {
-return (unsigned) (atan2 ((double) dy, (double) dx) * 10430.37835 + 0.5);
+    return (unsigned) (atan2((double) dy, (double) dx) * 10430.37835 + 0.5);
 }
 
 
@@ -47,11 +47,7 @@
    compute the distance from (0, 0) to (dx, dy)
 */
 
-unsigned ComputeDist (int dx, int dy)
+unsigned ComputeDist(int dx, int dy)
 {
-return (unsigned) (hypot ((double) dx, (double) dy) + 0.5);
+    return (unsigned) (hypot((double) dx, (double) dy) + 0.5);
 }
-
-
-
-
--- a/src/gfx.cc	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/gfx.cc	Sat Sep 24 14:16:04 2011 +0300
@@ -39,7 +39,7 @@
 #include "gcolour2.h"
 #include "gcolour3.h"
 #include "gfx.h"
-#include "levels.h"  /* Level */
+#include "levels.h"		/* Level */
 #include "x11.h"
 
 #ifdef Y_DOS
@@ -49,497 +49,499 @@
 
 /* Parameters set by the command line args and config file */
 const char *font_name = NULL;	// X: the name of the font to load
-Win_dim initial_window_width ("90%");	// X: the name says it all
-Win_dim initial_window_height ("90%");	// X: the name says it all
-int   no_pixmap;		// X: use no pixmap -- direct window output
-int   VideoMode = 2;		// BGI: default video mode for VESA cards
+Win_dim initial_window_width("90%");	// X: the name says it all
+Win_dim initial_window_height("90%");	// X: the name says it all
+int no_pixmap;			// X: use no pixmap -- direct window output
+int VideoMode = 2;		// BGI: default video mode for VESA cards
 
 /* Global variables */
-int GfxMode = 0;	// graphics mode number, or 0 for text
+int GfxMode = 0;		// graphics mode number, or 0 for text
 			// 1 = 320x200, 2 = 640x480, 3 = 800x600, 4 = 1kx768
 			// positive = 16 colors, negative = 256 colors
-int OrigX;		// Map X-coord of centre of screen/window
-int OrigY;		// Map Y-coord of centre of screen/window
-float Scale;		// the scale value
-int ScrMaxX;		// Maximum display X-coord of screen/window
-int ScrMaxY;		// Maximum display Y-coord of screen/window
-int ScrCenterX;		// Display X-coord of centre of screen/window
-int ScrCenterY;		// Display Y-coord of centre of screen/window
+int OrigX;			// Map X-coord of centre of screen/window
+int OrigY;			// Map Y-coord of centre of screen/window
+float Scale;			// the scale value
+int ScrMaxX;			// Maximum display X-coord of screen/window
+int ScrMaxY;			// Maximum display Y-coord of screen/window
+int ScrCenterX;			// Display X-coord of centre of screen/window
+int ScrCenterY;			// Display Y-coord of centre of screen/window
 unsigned FONTH;
 unsigned FONTW;
 int font_xofs;
 int font_yofs;
 
 
-Display *dpy;		// The X display
-int      scn;		// The X screen number
-Colormap cmap = 0;	// The X colormap
-GC       gc;		// Default GC as set by set_colour(), SetDrawingMode()
-                        // and SetLineThickness()
-GC       pixmap_gc;	// The GC used to clear the pixmap
-Window   win;		// The X window
-Pixmap   pixmap;	// The X pixmap (if any)
-Drawable drw;		// Points to either <win> or <pixmap>
-int      drw_mods;	// Number of modifications to drw since last call to
+Display *dpy;			// The X display
+int scn;			// The X screen number
+Colormap cmap = 0;		// The X colormap
+GC gc;				// Default GC as set by set_colour(), SetDrawingMode()
+			// and SetLineThickness()
+GC pixmap_gc;			// The GC used to clear the pixmap
+Window win;			// The X window
+Pixmap pixmap;			// The X pixmap (if any)
+Drawable drw;			// Points to either <win> or <pixmap>
+int drw_mods;			// Number of modifications to drw since last call to
 			// update_display(). Number of modifications to drw
 			// plus 1 since last call to ClearScreen().
-Visual  *win_vis;	// The visual for win */
-xpv_t    win_r_mask;	// The RGB masks for win's visual */
-xpv_t    win_g_mask;
-xpv_t    win_b_mask;
-int      win_r_bits;	// The RGB masks' respective lengths */
-int      win_g_bits;
-int      win_b_bits;
-int      win_r_ofs;	// The RGB masks' respective offsets relative to b0 */
-int      win_g_ofs;
-int      win_b_ofs;
-int      win_ncolours;	// The number of possible colours for win's visual.
+Visual *win_vis;		// The visual for win */
+xpv_t win_r_mask;		// The RGB masks for win's visual */
+xpv_t win_g_mask;
+xpv_t win_b_mask;
+int win_r_bits;			// The RGB masks' respective lengths */
+int win_g_bits;
+int win_b_bits;
+int win_r_ofs;			// The RGB masks' respective offsets relative to b0 */
+int win_g_ofs;
+int win_b_ofs;
+int win_ncolours;		// The number of possible colours for win's visual.
 			// If win_vis_class is TrueColor or DirectColor,
 			// it's the number of bits in the biggest subfield.
-int      win_vis_class;	// The class of win's visual
-VisualID win_vis_id;	// The ID of win's visual
-int      win_depth;	// The depth of win in bits
-int      x_server_big_endian = 0;	// Is the X server big endian ?
-int      ximage_bpp;	// Number of bytes per pixels in XImages
-int      ximage_quantum;// Pad XImages lines to a multiple of that many bytes
+int win_vis_class;		// The class of win's visual
+VisualID win_vis_id;		// The ID of win's visual
+int win_depth;			// The depth of win in bits
+int x_server_big_endian = 0;	// Is the X server big endian ?
+int ximage_bpp;			// Number of bytes per pixels in XImages
+int ximage_quantum;		// Pad XImages lines to a multiple of that many bytes
 static pcolour_t *app_colour = 0;	// Pixel values for the app. colours
-static int DrawingMode    = 0;		// 0 = copy, 1 = xor
-static int LineThickness  = 0;		// 0 = thin, 1 = thick
-int      text_dot         = 0;		// DrawScreenText() debug flag
+static int DrawingMode = 0;	// 0 = copy, 1 = xor
+static int LineThickness = 0;	// 0 = thin, 1 = thick
+int text_dot = 0;		// DrawScreenText() debug flag
 
 static acolour_t colour_stack[4];
-static int       colour_stack_pointer = 0;
-static Font      font_xfont;
-static bool      default_font = true;
+static int colour_stack_pointer = 0;
+static Font font_xfont;
+static bool default_font = true;
 
 /*
  *	InitGfx - initialize the graphics display
  *
  *	Return 0 on success, non-zero on failure
  */
-int InitGfx (void)
+int InitGfx(void)
 {
-  // Initialization is in fact not necessary
-  int width;
-  int height;
+    // Initialization is in fact not necessary
+    int width;
+    int height;
 
-  /*
-   *	Open display and get screen number
-   */
-  dpy = XOpenDisplay (0);
-  if (! dpy)
-  {
-    err ("Can't open display");
-    return 1;
-  }
-  scn = DefaultScreen (dpy);
-  {
-    verbmsg ("X: server endianness: ");
-    int r = ImageByteOrder (dpy);
-    if (r == LSBFirst)
+    /*
+     *    Open display and get screen number
+     */
+    dpy = XOpenDisplay(0);
+    if (!dpy)
     {
-      verbmsg ("little-endian\n");
-      x_server_big_endian = 0;
+	err("Can't open display");
+	return 1;
     }
-    else if (r == MSBFirst)
+    scn = DefaultScreen(dpy);
     {
-      verbmsg ("big-endian\n");
-      x_server_big_endian = 1;
-    }
-    else					// Can't happen
-    {
-      verbmsg ("unknown\n");
-      warn ("don't understand X server's endianness code %d\n", r);
-      warn ("assuming same endianness as CPU.\n");
-      x_server_big_endian = cpu_big_endian;
+	verbmsg("X: server endianness: ");
+	int r = ImageByteOrder(dpy);
+	if (r == LSBFirst)
+	{
+	    verbmsg("little-endian\n");
+	    x_server_big_endian = 0;
+	}
+	else if (r == MSBFirst)
+	{
+	    verbmsg("big-endian\n");
+	    x_server_big_endian = 1;
+	}
+	else			// Can't happen
+	{
+	    verbmsg("unknown\n");
+	    warn("don't understand X server's endianness code %d\n", r);
+	    warn("assuming same endianness as CPU.\n");
+	    x_server_big_endian = cpu_big_endian;
+	}
     }
-  }
-  int screen_width  = DisplayWidth  (dpy, scn);
-  int screen_height = DisplayHeight (dpy, scn);
-  // On QNX 6, XFree returns silly values. Use a plausible default instead.
-  if (screen_width == 16383 && screen_height == 16383)
-  {
-    warn ("QNX XFree bug detected (width %d, height %d)\n",
-	screen_width, screen_height);
-    screen_width  = 1024;
-    screen_height = 768;
-  }
+    int screen_width = DisplayWidth(dpy, scn);
+    int screen_height = DisplayHeight(dpy, scn);
+    // On QNX 6, XFree returns silly values. Use a plausible default instead.
+    if (screen_width == 16383 && screen_height == 16383)
+    {
+	warn("QNX XFree bug detected (width %d, height %d)\n",
+	     screen_width, screen_height);
+	screen_width = 1024;
+	screen_height = 768;
+    }
 
 
-  /*
-   *	Create the window
-   */
-  width  = initial_window_width.pixels  (screen_width);
-  height = initial_window_height.pixels (screen_height);
-  win = XCreateSimpleWindow (dpy, DefaultRootWindow (dpy),
-    10, 10, width, height, 0, 0, 0);
-  //win = DefaultRootWindow (dpy);
-  {
-    XWindowAttributes wa;
-    XVisualInfo model;
-    XVisualInfo *vis_info;
-    int nvisuals;
+    /*
+     *    Create the window
+     */
+    width = initial_window_width.pixels(screen_width);
+    height = initial_window_height.pixels(screen_height);
+    win = XCreateSimpleWindow(dpy, DefaultRootWindow(dpy),
+			      10, 10, width, height, 0, 0, 0);
+    //win = DefaultRootWindow (dpy);
+    {
+	XWindowAttributes wa;
+	XVisualInfo model;
+	XVisualInfo *vis_info;
+	int nvisuals;
+
+	XGetWindowAttributes(dpy, win, &wa);
+	win_vis = wa.visual;
+	win_depth = wa.depth;
+	verbmsg("X: window depth: %d b\n", win_depth);
 
-    XGetWindowAttributes (dpy, win, &wa);
-    win_vis   = wa.visual;
-    win_depth = wa.depth;
-    verbmsg ("X: window depth: %d b\n", win_depth);
+	/*
+	 *  Retrieve info regarding win's visual
+	 */
+	model.visualid = XVisualIDFromVisual(win_vis);
+	vis_info = XGetVisualInfo(dpy, VisualIDMask, &model, &nvisuals);
+	if (!vis_info)
+	    fatal_error("XGetVisualInfo returned NULL for ID %d",
+			model.visualid);
+	if (nvisuals != 1)
+	    fatal_error("XGetVisualInfo returned %d visuals", nvisuals);
+	if (vis_info->depth != win_depth)
+	    fatal_error("Visual depth %d <> win depth %d", vis_info->depth,
+			win_depth);
+	win_vis_id = vis_info->visualid;
+#if defined _cplusplus || defined __cplusplus
+	win_vis_class = vis_info->c_class;
+#else
+	win_vis_class = vis_info->class;
+#endif
+	win_ncolours = vis_info->colormap_size;
+	win_r_mask = vis_info->red_mask;
+	win_g_mask = vis_info->green_mask;
+	win_b_mask = vis_info->blue_mask;
+	XFree(vis_info);
+	verbmsg("X: visual: id %xh, class ", (unsigned) win_vis_id);
+	if (win_vis_class == PseudoColor)
+	    verbmsg("PseudoColor");
+	else if (win_vis_class == TrueColor)
+	    verbmsg("TrueColor");
+	else if (win_vis_class == DirectColor)
+	    verbmsg("DirectColor");
+	else if (win_vis_class == StaticColor)
+	    verbmsg("StaticColor");
+	else if (win_vis_class == GrayScale)
+	    verbmsg("GrayScale");
+	else if (win_vis_class == StaticGray)
+	    verbmsg("StaticGray");
+	else
+	    verbmsg("unknown (%d)", win_vis_class);
+	verbmsg(", colours %d, masks %08lX %08lX %08lX\n",
+		win_ncolours, win_r_mask, win_g_mask, win_b_mask);
+
+	// Compute win_[rgb]_bits and win_[rgb]_ofs
+	/* FIXME can enter infinite loop if MSb of either mask is set
+	   and >> sign extends. */
+	if (win_r_mask)
+	{
+	    xpv_t mask;
+	    for (mask = win_r_mask, win_r_ofs = 0; !(mask & 1); mask >>= 1)
+		win_r_ofs++;
+	    for (win_r_bits = 0; mask & 1; mask >>= 1)
+		win_r_bits++;
+	}
+	if (win_g_mask)
+	{
+	    xpv_t mask;
+	    for (mask = win_g_mask, win_g_ofs = 0; !(mask & 1); mask >>= 1)
+		win_g_ofs++;
+	    for (win_g_bits = 0; mask & 1; mask >>= 1)
+		win_g_bits++;
+	}
+	if (win_b_mask)
+	{
+	    xpv_t mask;
+	    for (mask = win_b_mask, win_b_ofs = 0; !(mask & 1); mask >>= 1)
+		win_b_ofs++;
+	    for (win_b_bits = 0; mask & 1; mask >>= 1)
+		win_b_bits++;
+	}
+	verbmsg("X: visual: " "r_ofs %d, r_bits %d, ", win_r_ofs, win_r_bits);
+	verbmsg("g_ofs %d, g_bits %d, ", win_g_ofs, win_g_bits);
+	verbmsg("b_ofs %d, b_bits %d\n", win_b_ofs, win_b_bits);
+    }
 
     /*
-     *	Retrieve info regarding win's visual
+     *    Get info relevant to XImages
      */
-    model.visualid = XVisualIDFromVisual (win_vis);
-    vis_info = XGetVisualInfo (dpy, VisualIDMask, &model, &nvisuals);
-    if (! vis_info)
-      fatal_error ("XGetVisualInfo returned NULL for ID %d", model.visualid);
-    if (nvisuals != 1)
-      fatal_error ("XGetVisualInfo returned %d visuals", nvisuals);
-    if (vis_info->depth != win_depth)
-      fatal_error ("Visual depth %d <> win depth %d", vis_info->depth, win_depth);
-    win_vis_id    = vis_info->visualid;
-#if defined _cplusplus || defined __cplusplus
-    win_vis_class = vis_info->c_class;
-#else
-    win_vis_class = vis_info->class;
-#endif
-    win_ncolours  = vis_info->colormap_size;
-    win_r_mask    = vis_info->red_mask;
-    win_g_mask    = vis_info->green_mask;
-    win_b_mask    = vis_info->blue_mask;
-    XFree (vis_info);
-    verbmsg ("X: visual: id %xh, class ", (unsigned) win_vis_id);
-    if (win_vis_class == PseudoColor)
-      verbmsg ("PseudoColor");
-    else if (win_vis_class == TrueColor)
-      verbmsg ("TrueColor");
-    else if (win_vis_class == DirectColor)
-      verbmsg ("DirectColor");
-    else if (win_vis_class == StaticColor)
-      verbmsg ("StaticColor");
-    else if (win_vis_class == GrayScale)
-      verbmsg ("GrayScale");
-    else if (win_vis_class == StaticGray)
-      verbmsg ("StaticGray");
-    else
-      verbmsg ("unknown (%d)", win_vis_class);
-    verbmsg (", colours %d, masks %08lX %08lX %08lX\n",
-      win_ncolours, win_r_mask, win_g_mask, win_b_mask);
-
-    // Compute win_[rgb]_bits and win_[rgb]_ofs
-    /* FIXME can enter infinite loop if MSb of either mask is set
-       and >> sign extends. */
-    if (win_r_mask)
+    ximage_bpp = 0;
+    ximage_quantum = 0;
     {
-      xpv_t mask;
-      for (mask = win_r_mask, win_r_ofs = 0; ! (mask & 1); mask >>= 1)
-	 win_r_ofs++;
-      for (win_r_bits = 0; mask & 1; mask >>= 1)
-	 win_r_bits++;
-    }
-    if (win_g_mask)
-    {
-      xpv_t mask;
-      for (mask = win_g_mask, win_g_ofs = 0; ! (mask & 1); mask >>= 1)
-	 win_g_ofs++;
-      for (win_g_bits = 0; mask & 1; mask >>= 1)
-	 win_g_bits++;
-    }
-    if (win_b_mask)
-    {
-      xpv_t mask;
-      for (mask = win_b_mask, win_b_ofs = 0; ! (mask & 1); mask >>= 1)
-	 win_b_ofs++;
-      for (win_b_bits = 0; mask & 1; mask >>= 1)
-	 win_b_bits++;
+	int nformats = 0;
+	XPixmapFormatValues *format = XListPixmapFormats(dpy, &nformats);
+	if (format == 0 || nformats < 1)
+	{
+	    warn("XListPixmapFormats() trouble (ret=%p, n=%d).\n", format,
+		 nformats);
+	    goto ximage_done;
+	}
+	/* Pick the best possible pixmap format. Prefer one that has the
+	   same depth as the drawable, as it is likely to be the fastest
+	   one. Should there be several formats that satisfy that
+	   requirement (I don't think that ever happens), prefer the one
+	   where the line quantum is equal to the number of bits per
+	   pixel, as that is easier to work with. */
+	{
+	    const XPixmapFormatValues *best = 0;
+	    for (int n = 0; n < nformats; n++)
+	    {
+		const XPixmapFormatValues *current = format + n;
+		verbmsg("X: pixmap format:"
+			" #%d, depth %2d, bits_per_pixel %2d, scanline_pad %2d\n",
+			n, current->depth, current->bits_per_pixel,
+			current->scanline_pad);
+		if (best == 0)
+		{
+		    best = current;
+		    continue;
+		}
+		int cgoodness = 2 * (current->depth == win_depth)
+		    + 1 * (current->scanline_pad == current->bits_per_pixel);
+		int bgoodness = 2 * (best->depth == win_depth)
+		    + 1 * (best->scanline_pad == best->bits_per_pixel);
+		if (cgoodness > bgoodness)
+		    best = current;
+	    }
+	    verbmsg("X: pixmap format: best is #%d\n", int (best - format));
+	    if (best != 0)
+	    {
+		int bits_per_pixel = best->bits_per_pixel;
+		if (bits_per_pixel % 8)	// Paranoia
+		{
+		    round_up(bits_per_pixel, 8);
+		    warn("XImage format has bad bits_per_pixel %d. Rounding up to %d.\n", best->bits_per_pixel, bits_per_pixel);
+		}
+		int scanline_pad = best->scanline_pad;
+		if (best->scanline_pad % 8)	// Paranoia
+		{
+		    round_up(scanline_pad, 8);
+		    warn("XImage format has bad scanline_pad %d. Rounding up to %d.\n", best->scanline_pad, scanline_pad);
+		}
+		ximage_bpp = bits_per_pixel / 8;
+		ximage_quantum = scanline_pad / 8;
+	    }
+	}
+	if (ximage_bpp == 0 || ximage_quantum == 0)
+	{
+	    warn("XListPixmapFormats() returned no suitable formats.\n");
+	    goto ximage_done;
+	}
+      ximage_done:
+	if (format != 0)
+	    XFree(format);
     }
-    verbmsg ("X: visual: "
-	     "r_ofs %d, r_bits %d, ", win_r_ofs, win_r_bits);
-    verbmsg ("g_ofs %d, g_bits %d, ", win_g_ofs, win_g_bits);
-    verbmsg ("b_ofs %d, b_bits %d\n", win_b_ofs, win_b_bits);
-  }
-
-  /*
-   *	Get info relevant to XImages
-   */
-  ximage_bpp     = 0;
-  ximage_quantum = 0;
-  {
-    int nformats = 0;
-    XPixmapFormatValues *format = XListPixmapFormats (dpy, &nformats);
-    if (format == 0 || nformats < 1)
-    {
-      warn ("XListPixmapFormats() trouble (ret=%p, n=%d).\n", format, nformats);
-      goto ximage_done;
-    }
-    /* Pick the best possible pixmap format. Prefer one that has the
-       same depth as the drawable, as it is likely to be the fastest
-       one. Should there be several formats that satisfy that
-       requirement (I don't think that ever happens), prefer the one
-       where the line quantum is equal to the number of bits per
-       pixel, as that is easier to work with. */
-    {
-      const XPixmapFormatValues *best = 0;
-      for (int n = 0; n < nformats; n++)
-      {
-	const XPixmapFormatValues *current = format + n;
-	verbmsg ("X: pixmap format:"
-	    " #%d, depth %2d, bits_per_pixel %2d, scanline_pad %2d\n",
-	    n, current->depth, current->bits_per_pixel, current->scanline_pad);
-	if (best == 0)
-	{
-	  best = current;
-	  continue;
-	}
-	int cgoodness = 2 * (current->depth == win_depth)
-		      + 1 * (current->scanline_pad == current->bits_per_pixel);
-	int bgoodness = 2 * (best->depth == win_depth)
-		      + 1 * (best->scanline_pad == best->bits_per_pixel);
-	if (cgoodness > bgoodness)
-	  best = current;
-      }
-      verbmsg ("X: pixmap format: best is #%d\n", int (best - format));
-      if (best != 0)
-      {
-	int bits_per_pixel = best->bits_per_pixel;
-	if (bits_per_pixel % 8)  // Paranoia
-	 {
-	   round_up (bits_per_pixel, 8);
-	   warn ("XImage format has bad bits_per_pixel %d. Rounding up to %d.\n",
-	      best->bits_per_pixel, bits_per_pixel);
-	 }
-	int scanline_pad = best->scanline_pad;
-	if (best->scanline_pad % 8)  // Paranoia
-	 {
-	   round_up (scanline_pad, 8);
-	   warn ("XImage format has bad scanline_pad %d. Rounding up to %d.\n",
-	      best->scanline_pad, scanline_pad);
-	 }
-	ximage_bpp     = bits_per_pixel / 8;
-	ximage_quantum = scanline_pad   / 8;
-      }
-    }
+    /* Could not obtain authoritative/good values. Warn and guess
+       plausible values. */
     if (ximage_bpp == 0 || ximage_quantum == 0)
     {
-      warn ("XListPixmapFormats() returned no suitable formats.\n"); 
-      goto ximage_done;
+	if (ximage_bpp == 0)
+	    ximage_bpp = (win_depth + 7) / 8;
+	if (ximage_quantum == 0)
+	    ximage_quantum = 4;
+	warn("guessing format. Images will probably not be displayed correctly\n");
     }
-    ximage_done:
-    if (format != 0)
-      XFree (format);
-  }
-  /* Could not obtain authoritative/good values. Warn and guess
-     plausible values. */
-  if (ximage_bpp == 0 || ximage_quantum == 0)
-  {
-    if (ximage_bpp == 0)
-      ximage_bpp = (win_depth + 7) / 8;
-    if (ximage_quantum == 0)
-      ximage_quantum = 4;
-    warn ("guessing format. Images will probably not be displayed correctly\n");
-  }
-  verbmsg ("X: pixmap format: %d B per pixel, %d B quantum.\n",
-    ximage_bpp, ximage_quantum);
+    verbmsg("X: pixmap format: %d B per pixel, %d B quantum.\n",
+	    ximage_bpp, ximage_quantum);
+
+    /*
+     *    Further configure the window
+     */
+    XStoreName(dpy, win, "Yadex");	// Temporary name -- will be overwritten
+    XSelectInput(dpy, win,
+		 KeyPressMask | KeyReleaseMask
+		 | ButtonPressMask | ButtonReleaseMask
+		 | PointerMotionMask
+		 | EnterWindowMask | LeaveWindowMask
+		 | ExposureMask | StructureNotifyMask);
+
+    /*
+     *    Possibly load and query the font
+     */
+    {
+	XFontStruct *xqf;
 
-  /*
-   *	Further configure the window
-   */
-  XStoreName (dpy, win, "Yadex");  // Temporary name -- will be overwritten
-  XSelectInput (dpy, win,
-    KeyPressMask | KeyReleaseMask
-    | ButtonPressMask | ButtonReleaseMask
-    | PointerMotionMask
-    | EnterWindowMask | LeaveWindowMask
-    | ExposureMask
-    | StructureNotifyMask);
+	// Load the font or use the default font.
+	default_font = true;
+	if (font_name != NULL)
+	{
+	    x_catch_on();	// Catch errors in XLoadFont()
+	    font_xfont = XLoadFont(dpy, font_name);
+	    if (const char *err_msg = x_error())
+	    {
+		warn("can't load font \"%s\" (%s).\n", font_name, err_msg);
+		warn("using default font instead.\n");
+	    }
+	    else
+		default_font = false;
+	    x_catch_off();
+	}
 
-  /*
-   *	Possibly load and query the font
-   */
-  {
-    XFontStruct *xqf;
-
-    // Load the font or use the default font.
-    default_font = true;
-    if (font_name != NULL)
-    {
-      x_catch_on ();  // Catch errors in XLoadFont()
-      font_xfont = XLoadFont (dpy, font_name);
-      if (const char *err_msg = x_error ())
-      {
-	warn ("can't load font \"%s\" (%s).\n", font_name, err_msg);
-	warn ("using default font instead.\n");
-      }
-      else
-	 default_font = false;
-      x_catch_off ();
+	// Query the font we'll use for FONTW, FONTH and FONTYOFS.
+	xqf = XQueryFont(dpy,
+			 default_font ? XGContextFromGC(DefaultGC(dpy, scn)) :
+			 font_xfont);
+	if (xqf->direction != FontLeftToRight)
+	    warn("this font is not left-to-right !\n");
+	if (xqf->min_byte1 != 0 || xqf->max_byte1 != 0)
+	    warn("this is not a single-byte font !\n");
+	if (xqf->min_char_or_byte2 > 32 || xqf->max_char_or_byte2 < 126)
+	    warn("this font does not support the ASCII character set !\n");
+	if (xqf->min_bounds.width != xqf->max_bounds.width)
+	    warn("this is not a fixed-width font !\n");
+	FONTW = xqf->max_bounds.width;
+	FONTH = xqf->ascent + xqf->descent;
+	font_xofs = xqf->min_bounds.lbearing;
+	font_yofs = xqf->max_bounds.ascent;
+	XFreeFontInfo(NULL, xqf, 1);
+	verbmsg("X: font: metrics: %dx%d, xofs %d, yofs %d\n",
+		FONTW, FONTH, font_xofs, font_yofs);
     }
 
-    // Query the font we'll use for FONTW, FONTH and FONTYOFS.
-    xqf = XQueryFont (dpy,
-      default_font ? XGContextFromGC (DefaultGC (dpy, scn)) : font_xfont);
-    if (xqf->direction != FontLeftToRight)
-      warn ("this font is not left-to-right !\n");
-    if (xqf->min_byte1 != 0 || xqf->max_byte1 != 0)
-      warn ("this is not a single-byte font !\n");
-    if (xqf->min_char_or_byte2 > 32 || xqf->max_char_or_byte2 < 126)
-      warn ("this font does not support the ASCII character set !\n");
-    if (xqf->min_bounds.width != xqf->max_bounds.width)
-      warn ("this is not a fixed-width font !\n");
-    FONTW     = xqf->max_bounds.width;
-    FONTH     = xqf->ascent + xqf->descent;
-    font_xofs = xqf->min_bounds.lbearing;
-    font_yofs = xqf->max_bounds.ascent;
-    XFreeFontInfo (NULL, xqf, 1);
-    verbmsg ("X: font: metrics: %dx%d, xofs %d, yofs %d\n",
-      FONTW, FONTH, font_xofs, font_yofs);
-  }
+    /*
+     *    Get/create the colormap
+     *    and allocate the colours.
+     */
+    if (win_vis_class == PseudoColor)
+    {
+	verbmsg("X: running on PseudoColor visual, using private Colormap\n");
+	cmap = XCreateColormap(dpy, win, win_vis, AllocNone);
+    }
+    else
+	cmap = DefaultColormap(dpy, scn);
+
+    XSetWindowColormap(dpy, win, cmap);
+    game_colour = alloc_game_colours(0);
+    app_colour = commit_app_colours();
+    if (win_depth == 24)
+	game_colour_24.refresh(game_colour, x_server_big_endian);
 
-  /*
-   *	Get/create the colormap
-   *	and allocate the colours.
-   */
-  if (win_vis_class == PseudoColor)
-  {
-    verbmsg ("X: running on PseudoColor visual, using private Colormap\n");
-    cmap = XCreateColormap (dpy, win, win_vis, AllocNone);
-  }
-  else
-    cmap = DefaultColormap (dpy, scn);
-
-  XSetWindowColormap (dpy, win, cmap);
-  game_colour = alloc_game_colours (0);
-  app_colour = commit_app_colours ();
-  if (win_depth == 24)
-    game_colour_24.refresh (game_colour, x_server_big_endian);
+    /*
+     *    Create the GC
+     */
+    {
+	XGCValues gcv;
+	unsigned long mask;
 
-  /*
-   *	Create the GC
-   */
-  {
-    XGCValues gcv;
-    unsigned long mask;
-
-    mask = GCForeground | GCFunction | GCLineWidth;
-    if (! default_font)
-    {
-      mask |= GCFont;
-      gcv.font = font_xfont;
+	mask = GCForeground | GCFunction | GCLineWidth;
+	if (!default_font)
+	{
+	    mask |= GCFont;
+	    gcv.font = font_xfont;
+	}
+	gcv.foreground = app_colour[0];	// Default colour
+	gcv.line_width = 0;
+	gcv.function = GXcopy;
+	gc = XCreateGC(dpy, win, mask, &gcv);
+	if (gc == 0)
+	    fatal_error("XCreateGC() returned NULL");
     }
-    gcv.foreground = app_colour[0];  // Default colour
-    gcv.line_width = 0;
-    gcv.function   = GXcopy;
-    gc = XCreateGC (dpy, win, mask, &gcv);
-    if (gc == 0)
-      fatal_error ("XCreateGC() returned NULL");
-  }
 
 
-  /*
-   *	More stuff
-   */
-  XSetWindowBackground (dpy, win, app_colour[0]);
-  XMapWindow (dpy, win);
+    /*
+     *    More stuff
+     */
+    XSetWindowBackground(dpy, win, app_colour[0]);
+    XMapWindow(dpy, win);
 
-  // Unless no_pixmap is set, create the pixmap and its own pet GC.
-  if (no_pixmap)
-    drw = win;
-  else
-  {
-    XGCValues gcv;
+    // Unless no_pixmap is set, create the pixmap and its own pet GC.
+    if (no_pixmap)
+	drw = win;
+    else
+    {
+	XGCValues gcv;
 
-    pixmap = XCreatePixmap (dpy, win, width, height, win_depth);
-    gcv.foreground = app_colour[0];
-    gcv.graphics_exposures = False;  // We don't want NoExpose events
-    pixmap_gc = XCreateGC (dpy, pixmap, GCForeground | GCGraphicsExposures,
-	&gcv);
-    drw = win;
-    drw_mods = 0;  // Force display the first time
-  }
-  XSync (dpy, False);
-  GfxMode = - VideoMode;
+	pixmap = XCreatePixmap(dpy, win, width, height, win_depth);
+	gcv.foreground = app_colour[0];
+	gcv.graphics_exposures = False;	// We don't want NoExpose events
+	pixmap_gc = XCreateGC(dpy, pixmap, GCForeground | GCGraphicsExposures,
+			      &gcv);
+	drw = win;
+	drw_mods = 0;		// Force display the first time
+    }
+    XSync(dpy, False);
+    GfxMode = -VideoMode;
 
-  SetWindowSize (width, height);
-  return 0;
+    SetWindowSize(width, height);
+    return 0;
 }
 
 
 /*
  *	TermGfx - terminate the graphics display
  */
-void TermGfx ()
+void TermGfx()
 {
-  verbmsg ("TermGfx: GfxMode=%d\n", GfxMode);
-  if (GfxMode)
-  {
-    int r;
+    verbmsg("TermGfx: GfxMode=%d\n", GfxMode);
+    if (GfxMode)
+    {
+	int r;
 
-    if (! no_pixmap)
-    {
-      XFreePixmap (dpy, pixmap);
-      XFreeGC     (dpy, pixmap_gc);
+	if (!no_pixmap)
+	{
+	    XFreePixmap(dpy, pixmap);
+	    XFreeGC(dpy, pixmap_gc);
+	}
+	r = XDestroyWindow(dpy, win);
+	verbmsg("X: XDestroyWindow returned %d\n", r);
+	free_game_colours(game_colour);
+	game_colour = 0;
+	uncommit_app_colours(app_colour);
+	app_colour = 0;
+	if (cmap != DefaultColormap(dpy, scn))
+	{
+	    verbmsg("X: freeing Colormap\n");
+	    XFreeColormap(dpy, cmap);
+	}
+	if (!default_font)
+	{
+	    verbmsg("X: unloading font\n");
+	    XUnloadFont(dpy, font_xfont);
+	}
+	XFreeGC(dpy, gc);
+	gc = 0;
+	// FIXME there is surely more to do...
+	XCloseDisplay(dpy);
+
+	GfxMode = 0;
     }
-    r = XDestroyWindow (dpy, win);
-    verbmsg ("X: XDestroyWindow returned %d\n", r);
-    free_game_colours (game_colour);
-    game_colour = 0;
-    uncommit_app_colours (app_colour);
-    app_colour = 0;
-    if (cmap != DefaultColormap (dpy, scn))
-    {
-      verbmsg ("X: freeing Colormap\n");
-      XFreeColormap  (dpy, cmap);
-    }
-    if (! default_font)
-    {
-      verbmsg ("X: unloading font\n");
-      XUnloadFont (dpy, font_xfont);
-    }
-    XFreeGC (dpy, gc);
-    gc = 0;
-    // FIXME there is surely more to do...
-    XCloseDisplay (dpy);
-
-    GfxMode = 0;
-  }
 }
 
 
 /*
  *	SetWindowSize - set the size of the edit window
  */
-void SetWindowSize (int width, int height)
+void SetWindowSize(int width, int height)
 {
-  // Am I called uselessly ?
-  if (width == ScrMaxX + 1 && height == ScrMaxY + 1)
-    return;
+    // Am I called uselessly ?
+    if (width == ScrMaxX + 1 && height == ScrMaxY + 1)
+	return;
 
-  ScrMaxX = width - 1;
-  ScrMaxY = height - 1;
-  ScrCenterX = ScrMaxX / 2;
-  ScrCenterY = ScrMaxY / 2;
+    ScrMaxX = width - 1;
+    ScrMaxY = height - 1;
+    ScrCenterX = ScrMaxX / 2;
+    ScrCenterY = ScrMaxY / 2;
 
-  // Replace the old pixmap by another of the new size
-  if (! no_pixmap)
-  {
-    XFreePixmap (dpy, pixmap);
-    pixmap = XCreatePixmap (dpy, win, width, height, win_depth);
-    drw = pixmap;
-  }
+    // Replace the old pixmap by another of the new size
+    if (!no_pixmap)
+    {
+	XFreePixmap(dpy, pixmap);
+	pixmap = XCreatePixmap(dpy, win, width, height, win_depth);
+	drw = pixmap;
+    }
 }
 
 
 /*
  *	ClearScreen - clear the screen
  */
-void ClearScreen ()
+void ClearScreen()
 {
-  if (no_pixmap)
-    XClearWindow (dpy, win);
-  else
-  {
-    XFillRectangle (dpy, pixmap, pixmap_gc, 0, 0, ScrMaxX + 1, ScrMaxY + 1);
-    drw = pixmap;  // Redisplaying from scratch so let's use the pixmap
-  }
+    if (no_pixmap)
+	XClearWindow(dpy, win);
+    else
+    {
+	XFillRectangle(dpy, pixmap, pixmap_gc, 0, 0, ScrMaxX + 1,
+		       ScrMaxY + 1);
+	drw = pixmap;		// Redisplaying from scratch so let's use the pixmap
+    }
 }
 
 
@@ -555,22 +557,23 @@
  *	the window, not on the pixmap so no need to copy the
  *	pixmap onto the window.
  */
-void update_display ()
+void update_display()
 {
-  //if (drw_mods == 0)  // Nothing to do, display is already up to date
-  //   return;
-  //printf (" [");
-  //fflush (stdout);
-  if (! no_pixmap && drw == pixmap)
-  {
-    //putchar ('*');
-    XCopyArea (dpy, pixmap, win, pixmap_gc, 0, 0, ScrMaxX+1, ScrMaxY+1, 0, 0);
-  }
-  XFlush (dpy);
-  //printf ("] ");
-  //fflush (stdout);
-  drw_mods = 0;
-  drw = win;  // If they don't like it, they can call ClearScreen() [HHOS]
+    //if (drw_mods == 0)  // Nothing to do, display is already up to date
+    //   return;
+    //printf (" [");
+    //fflush (stdout);
+    if (!no_pixmap && drw == pixmap)
+    {
+	//putchar ('*');
+	XCopyArea(dpy, pixmap, win, pixmap_gc, 0, 0, ScrMaxX + 1, ScrMaxY + 1,
+		  0, 0);
+    }
+    XFlush(dpy);
+    //printf ("] ");
+    //fflush (stdout);
+    drw_mods = 0;
+    drw = win;			// If they don't like it, they can call ClearScreen() [HHOS]
 }
 
 
@@ -582,9 +585,9 @@
  *
  *	FIXME this is not a clean way to do things.
  */
-void force_window_not_pixmap ()
+void force_window_not_pixmap()
 {
-  drw = win;
+    drw = win;
 }
 
 
@@ -593,9 +596,9 @@
  *
  *	<colour> must be an physical colour number (a.k.a. pixel value).
  */
-void set_pcolour (pcolour_t colour)
+void set_pcolour(pcolour_t colour)
 {
-  XSetForeground (dpy, gc, (xpv_t) colour);
+    XSetForeground(dpy, gc, (xpv_t) colour);
 }
 
 
@@ -606,9 +609,9 @@
 /*
  *	get_colour - get the current drawing colour
  */
-acolour_t get_colour ()
+acolour_t get_colour()
 {
-  return current_acolour;
+    return current_acolour;
 }
 
 
@@ -617,13 +620,13 @@
  *
  *	<colour> must be an application colour number.
  */
-void set_colour (acolour_t colour)
+void set_colour(acolour_t colour)
 {
-  if (colour != current_acolour)
-  {
-    current_acolour = colour;
-    XSetForeground (dpy, gc, app_colour[colour]);
-  }
+    if (colour != current_acolour)
+    {
+	current_acolour = colour;
+	XSetForeground(dpy, gc, app_colour[colour]);
+    }
 }
 
 
@@ -633,16 +636,17 @@
  *	Like set_colour() except that it will only last until
  *	the next call to pop_colour().
  */
-void push_colour (acolour_t colour)
+void push_colour(acolour_t colour)
 {
-  if (colour_stack_pointer >= (int) (sizeof colour_stack / sizeof *colour_stack))
-  {
-    nf_bug ("Colour stack overflow");
-    return;
-  }
-  colour_stack[colour_stack_pointer] = current_acolour;
-  colour_stack_pointer++;
-  set_colour (colour);
+    if (colour_stack_pointer >=
+	(int) (sizeof colour_stack / sizeof *colour_stack))
+    {
+	nf_bug("Colour stack overflow");
+	return;
+    }
+    colour_stack[colour_stack_pointer] = current_acolour;
+    colour_stack_pointer++;
+    set_colour(colour);
 }
 
 
@@ -651,50 +655,50 @@
  *
  *	Cancel the effect of the last call to push_colour().
  */
-void pop_colour (void)
+void pop_colour(void)
 {
-  if (colour_stack_pointer < 1)
-  {
-    nf_bug ("Colour stack underflow");
-    return;
-  }
-  colour_stack_pointer--;
-  set_colour (colour_stack[colour_stack_pointer]);
+    if (colour_stack_pointer < 1)
+    {
+	nf_bug("Colour stack underflow");
+	return;
+    }
+    colour_stack_pointer--;
+    set_colour(colour_stack[colour_stack_pointer]);
 }
 
 
 /*
  *	SetLineThickness - set the line style (thin or thick)
  */
-void SetLineThickness (int thick)
+void SetLineThickness(int thick)
 {
-  if (!! thick != LineThickness)
-  {
-    LineThickness = !! thick;
-    XGCValues gcv;
-    gcv.line_width = LineThickness ? 3 : (DrawingMode ? 1 : 0);
-    // ^ It's important to use a line_width of 1 when in xor mode.
-    // See note (1) in the hacker's guide.
-    XChangeGC (dpy, gc, GCLineWidth, &gcv);
-  }
+    if (! !thick != LineThickness)
+    {
+	LineThickness = ! !thick;
+	XGCValues gcv;
+	gcv.line_width = LineThickness ? 3 : (DrawingMode ? 1 : 0);
+	// ^ It's important to use a line_width of 1 when in xor mode.
+	// See note (1) in the hacker's guide.
+	XChangeGC(dpy, gc, GCLineWidth, &gcv);
+    }
 }
 
 
 /*
  *	SetDrawingMode - set the drawing mode (copy or xor)
  */
-void SetDrawingMode (int _xor)
+void SetDrawingMode(int _xor)
 {
-  if (!! _xor != DrawingMode)
-  {
-    DrawingMode = !! _xor;
-    XGCValues gcv;
-    gcv.function = DrawingMode ? GXxor : GXcopy;
-    gcv.line_width = LineThickness ? 3 : (DrawingMode ? 1 : 0);
-    // ^ It's important to use a line_width of 1 when in xor mode.
-    // See note (1) in the hacker's guide.
-    XChangeGC (dpy, gc, GCFunction | GCLineWidth, &gcv);
-  }
+    if (! !_xor != DrawingMode)
+    {
+	DrawingMode = ! !_xor;
+	XGCValues gcv;
+	gcv.function = DrawingMode ? GXxor : GXcopy;
+	gcv.line_width = LineThickness ? 3 : (DrawingMode ? 1 : 0);
+	// ^ It's important to use a line_width of 1 when in xor mode.
+	// See note (1) in the hacker's guide.
+	XChangeGC(dpy, gc, GCFunction | GCLineWidth, &gcv);
+    }
 }
 
 
@@ -703,9 +707,9 @@
  *
  *	The point is drawn at display coordinates (<x>, <y>).
  */
-void draw_point (int x, int y)
+void draw_point(int x, int y)
 {
-  XDrawPoint (dpy, drw, gc, x, y);
+    XDrawPoint(dpy, drw, gc, x, y);
 }
 
 
@@ -714,33 +718,34 @@
  *
  *	The point is drawn at map coordinates (<mapx>, <mapy>)
  */
-void draw_map_point (int mapx, int mapy)
+void draw_map_point(int mapx, int mapy)
 {
-  XDrawPoint (dpy, drw, gc, SCREENX (mapx), SCREENY (mapy));
-  drw_mods++;
+    XDrawPoint(dpy, drw, gc, SCREENX(mapx), SCREENY(mapy));
+    drw_mods++;
 }
 
 
 /*
  *	DrawMapLine - draw a line on the screen from map coords
  */
-void DrawMapLine (int mapx1, int mapy1, int mapx2, int mapy2)
+void DrawMapLine(int mapx1, int mapy1, int mapx2, int mapy2)
 {
-  XDrawLine (dpy, drw, gc, SCREENX (mapx1), SCREENY (mapy1),
-			   SCREENX (mapx2), SCREENY (mapy2));
-  drw_mods++;
+    XDrawLine(dpy, drw, gc, SCREENX(mapx1), SCREENY(mapy1),
+	      SCREENX(mapx2), SCREENY(mapy2));
+    drw_mods++;
 }
 
 
 /*
  *	DrawMapCircle - draw a circle on the screen from map coords
  */
-void DrawMapCircle (int mapx, int mapy, int mapradius)
+void DrawMapCircle(int mapx, int mapy, int mapradius)
 {
-  XDrawArc (dpy, drw, gc, SCREENX (mapx - mapradius), SCREENY (mapy + mapradius),
-    (unsigned int) (2 * mapradius * Scale),
-    (unsigned int) (2 * mapradius * Scale), 0, 360*64);
-  drw_mods++;
+    XDrawArc(dpy, drw, gc, SCREENX(mapx - mapradius),
+	     SCREENY(mapy + mapradius),
+	     (unsigned int) (2 * mapradius * Scale),
+	     (unsigned int) (2 * mapradius * Scale), 0, 360 * 64);
+    drw_mods++;
 }
 
 
@@ -748,86 +753,102 @@
 /*
  *	DrawMapVector - draw an arrow on the screen from map coords
  */
-void DrawMapVector (int mapx1, int mapy1, int mapx2, int mapy2)
+void DrawMapVector(int mapx1, int mapy1, int mapx2, int mapy2)
 {
-  int    scrx1   = SCREENX (mapx1);
-  int    scry1   = SCREENY (mapy1);
-  int    scrx2   = SCREENX (mapx2);
-  int    scry2   = SCREENY (mapy2);
-  double r       = hypot ((double) (scrx1 - scrx2), (double) (scry1 - scry2));
+    int scrx1 = SCREENX(mapx1);
+    int scry1 = SCREENY(mapy1);
+    int scrx2 = SCREENX(mapx2);
+    int scry2 = SCREENY(mapy2);
+    double r = hypot((double) (scrx1 - scrx2), (double) (scry1 - scry2));
 
 #if 0
-  /* AYM 19980216 to avoid getting huge arrowheads when zooming in */
-  int    scrXoff = (r >= 1.0) ? (int) ((scrx1 - scrx2) * 8.0 / r * (Scale < 1 ? Scale : 1)) : 0;
-  int    scrYoff = (r >= 1.0) ? (int) ((scry1 - scry2) * 8.0 / r * (Scale < 1 ? Scale : 1)) : 0;
+    /* AYM 19980216 to avoid getting huge arrowheads when zooming in */
+    int scrXoff =
+	(r >=
+	 1.0) ? (int) ((scrx1 - scrx2) * 8.0 / r * (Scale <
+						    1 ? Scale : 1)) : 0;
+    int scrYoff =
+	(r >=
+	 1.0) ? (int) ((scry1 - scry2) * 8.0 / r * (Scale <
+						    1 ? Scale : 1)) : 0;
 #else
-  int    scrXoff = (r >= 1.0) ? (int) ((scrx1 - scrx2) * 8.0 / r * (Scale / 2)) : 0;
-  int    scrYoff = (r >= 1.0) ? (int) ((scry1 - scry2) * 8.0 / r * (Scale / 2)) : 0;
+    int scrXoff =
+	(r >= 1.0) ? (int) ((scrx1 - scrx2) * 8.0 / r * (Scale / 2)) : 0;
+    int scrYoff =
+	(r >= 1.0) ? (int) ((scry1 - scry2) * 8.0 / r * (Scale / 2)) : 0;
 #endif
 
-  XDrawLine (dpy, drw, gc, scrx1, scry1, scrx2, scry2);
-  scrx1 = scrx2 + 2 * scrXoff;
-  scry1 = scry2 + 2 * scrYoff;
-  XDrawLine (dpy, drw, gc, scrx1 - scrYoff, scry1 + scrXoff, scrx2, scry2);
-  XDrawLine (dpy, drw, gc, scrx1 + scrYoff, scry1 - scrXoff, scrx2, scry2);
-  drw_mods++;
+    XDrawLine(dpy, drw, gc, scrx1, scry1, scrx2, scry2);
+    scrx1 = scrx2 + 2 * scrXoff;
+    scry1 = scry2 + 2 * scrYoff;
+    XDrawLine(dpy, drw, gc, scrx1 - scrYoff, scry1 + scrXoff, scrx2, scry2);
+    XDrawLine(dpy, drw, gc, scrx1 + scrYoff, scry1 - scrXoff, scrx2, scry2);
+    drw_mods++;
 }
 
 
 /*
  *	DrawMapArrow - draw an arrow on the screen from map coords and angle (0 - 65535)
  */
-void DrawMapArrow (int mapx1, int mapy1, unsigned angle)
+void DrawMapArrow(int mapx1, int mapy1, unsigned angle)
 {
-  int    mapx2   = mapx1 + (int) (50 * cos (angle / 10430.37835));
-  int    mapy2   = mapy1 + (int) (50 * sin (angle / 10430.37835));
-  int    scrx1   = SCREENX (mapx1);
-  int    scry1   = SCREENY (mapy1);
-  int    scrx2   = SCREENX (mapx2);
-  int    scry2   = SCREENY (mapy2);
-  double r       = hypot (scrx1 - scrx2, scry1 - scry2);
+    int mapx2 = mapx1 + (int) (50 * cos(angle / 10430.37835));
+    int mapy2 = mapy1 + (int) (50 * sin(angle / 10430.37835));
+    int scrx1 = SCREENX(mapx1);
+    int scry1 = SCREENY(mapy1);
+    int scrx2 = SCREENX(mapx2);
+    int scry2 = SCREENY(mapy2);
+    double r = hypot(scrx1 - scrx2, scry1 - scry2);
 #if 0
-  int    scrXoff = (r >= 1.0) ? (int) ((scrx1 - scrx2) * 8.0 / r * (Scale < 1 ? Scale : 1)) : 0;
-  int    scrYoff = (r >= 1.0) ? (int) ((scry1 - scry2) * 8.0 / r * (Scale < 1 ? Scale : 1)) : 0;
+    int scrXoff =
+	(r >=
+	 1.0) ? (int) ((scrx1 - scrx2) * 8.0 / r * (Scale <
+						    1 ? Scale : 1)) : 0;
+    int scrYoff =
+	(r >=
+	 1.0) ? (int) ((scry1 - scry2) * 8.0 / r * (Scale <
+						    1 ? Scale : 1)) : 0;
 #else
-  int    scrXoff = (r >= 1.0) ? (int) ((scrx1 - scrx2) * 8.0 / r * (Scale / 2)) : 0;
-  int    scrYoff = (r >= 1.0) ? (int) ((scry1 - scry2) * 8.0 / r * (Scale / 2)) : 0;
+    int scrXoff =
+	(r >= 1.0) ? (int) ((scrx1 - scrx2) * 8.0 / r * (Scale / 2)) : 0;
+    int scrYoff =
+	(r >= 1.0) ? (int) ((scry1 - scry2) * 8.0 / r * (Scale / 2)) : 0;
 #endif
 
-  XDrawLine (dpy, drw, gc, scrx1, scry1, scrx2, scry2);
-  scrx1 = scrx2 + 2 * scrXoff;
-  scry1 = scry2 + 2 * scrYoff;
-  XDrawLine (dpy, drw, gc, scrx1 - scrYoff, scry1 + scrXoff, scrx2, scry2);
-  XDrawLine (dpy, drw, gc, scrx1 + scrYoff, scry1 - scrXoff, scrx2, scry2);
-  drw_mods++;
+    XDrawLine(dpy, drw, gc, scrx1, scry1, scrx2, scry2);
+    scrx1 = scrx2 + 2 * scrXoff;
+    scry1 = scry2 + 2 * scrYoff;
+    XDrawLine(dpy, drw, gc, scrx1 - scrYoff, scry1 + scrXoff, scrx2, scry2);
+    XDrawLine(dpy, drw, gc, scrx1 + scrYoff, scry1 - scrXoff, scrx2, scry2);
+    drw_mods++;
 }
 
 
 /*
  *	DrawScreenLine - draw a line on the screen from screen coords
  */
-void DrawScreenLine (int Xstart, int Ystart, int Xend, int Yend)
+void DrawScreenLine(int Xstart, int Ystart, int Xend, int Yend)
 {
-  XDrawLine (dpy, drw, gc, Xstart, Ystart, Xend, Yend);
-  drw_mods++;
+    XDrawLine(dpy, drw, gc, Xstart, Ystart, Xend, Yend);
+    drw_mods++;
 }
 
 
 /*
  *	DrawScreenLineLen - draw a line on the screen
  */
-void DrawScreenLineLen (int x, int y, int width, int height)
+void DrawScreenLineLen(int x, int y, int width, int height)
 {
-  if (width > 0)
-    width--;
-  else if (width < 0)
-    width++;
-  if (height > 0)
-    height--;
-  else if (height < 0)
-    height++;
-  XDrawLine (dpy, drw, gc, x, y, x + width, y + height);
-  drw_mods++;
+    if (width > 0)
+	width--;
+    else if (width < 0)
+	width++;
+    if (height > 0)
+	height--;
+    else if (height < 0)
+	height++;
+    XDrawLine(dpy, drw, gc, x, y, x + width, y + height);
+    drw_mods++;
 }
 
 
@@ -837,10 +858,10 @@
  *	Unlike most functions here, the 3rd and 4th parameters
  *	specify lengths, not coordinates.
  */
-void DrawScreenRect (int x, int y, int width, int height)
+void DrawScreenRect(int x, int y, int width, int height)
 {
-  XDrawRectangle (dpy, drw, gc, x, y, width - 1, height - 1);
-  drw_mods++;
+    XDrawRectangle(dpy, drw, gc, x, y, width - 1, height - 1);
+    drw_mods++;
 }
 
 
@@ -851,15 +872,15 @@
  *	(scrx2, scry2) is the bottom right corner
  *	If scrx2 < scrx1 or scry2 < scry1, the function does nothing.
  */
-void DrawScreenBox (int scrx1, int scry1, int scrx2, int scry2)
+void DrawScreenBox(int scrx1, int scry1, int scrx2, int scry2)
 {
-  if (scrx2 < scrx1 || scry2 < scry1)
-    return;
+    if (scrx2 < scrx1 || scry2 < scry1)
+	return;
 
-  // FIXME missing gc fill_style
-  XFillRectangle (dpy, drw, gc, scrx1, scry1,
-    scrx2 - scrx1 + 1, scry2 - scry1 + 1);
-  drw_mods++;
+    // FIXME missing gc fill_style
+    XFillRectangle(dpy, drw, gc, scrx1, scry1,
+		   scrx2 - scrx1 + 1, scry2 - scry1 + 1);
+    drw_mods++;
 }
 
 
@@ -870,14 +891,14 @@
  *	(width, height) is the obvious
  *	If width < 1 or height < 1, does nothing.
  */
-void DrawScreenBoxwh (int scrx0, int scry0, int width, int height)
+void DrawScreenBoxwh(int scrx0, int scry0, int width, int height)
 {
-  if (width < 1 || height < 1)
-    return;
+    if (width < 1 || height < 1)
+	return;
 
-  // FIXME missing gc fill_style
-  XFillRectangle (dpy, drw, gc, scrx0, scry0, width, height);
-  drw_mods++;
+    // FIXME missing gc fill_style
+    XFillRectangle(dpy, drw, gc, scrx0, scry0, width, height);
+    drw_mods++;
 }
 
 
@@ -886,21 +907,21 @@
  *
  *	The 3D border is rather wide (BOX_BORDER pixels wide).
  */
-void DrawScreenBox3D (int scrx1, int scry1, int scrx2, int scry2)
+void DrawScreenBox3D(int scrx1, int scry1, int scrx2, int scry2)
 {
-  DrawScreenBox3DShallow (scrx1, scry1, scrx2, scry2);
-  push_colour (WINBG_DARK);
+    DrawScreenBox3DShallow(scrx1, scry1, scrx2, scry2);
+    push_colour(WINBG_DARK);
 
-  XDrawLine (dpy, drw, gc, scrx1 + 1, scry2 - 1, scrx2 - 1, scry2 - 1);
-  XDrawLine (dpy, drw, gc, scrx2 - 1, scry1 + 1, scrx2 - 1, scry2 - 1);
+    XDrawLine(dpy, drw, gc, scrx1 + 1, scry2 - 1, scrx2 - 1, scry2 - 1);
+    XDrawLine(dpy, drw, gc, scrx2 - 1, scry1 + 1, scrx2 - 1, scry2 - 1);
 
-  set_colour (WINBG_LIGHT);
+    set_colour(WINBG_LIGHT);
 
-  XDrawLine (dpy, drw, gc, scrx1 + 1, scry1 + 1, scrx1 + 1, scry2 - 1);
-  XDrawLine (dpy, drw, gc, scrx1 + 1, scry1 + 1, scrx2 - 1, scry1 + 1);
-  drw_mods++;
+    XDrawLine(dpy, drw, gc, scrx1 + 1, scry1 + 1, scrx1 + 1, scry2 - 1);
+    XDrawLine(dpy, drw, gc, scrx1 + 1, scry1 + 1, scrx2 - 1, scry1 + 1);
+    drw_mods++;
 
-  pop_colour ();
+    pop_colour();
 }
 
 
@@ -910,18 +931,19 @@
  *	Same thing as DrawScreenBox3D but shallow (the 3D border
  *	is NARROW_BORDER pixels wide).
  */
-void DrawScreenBox3DShallow (int scrx1, int scry1, int scrx2, int scry2)
+void DrawScreenBox3DShallow(int scrx1, int scry1, int scrx2, int scry2)
 {
-  push_colour (WINBG);
-  XFillRectangle (dpy, drw, gc, scrx1+1, scry1+1, scrx2-scrx1, scry2-scry1);
-  set_colour (WINBG_DARK);
-  XDrawLine (dpy, drw, gc, scrx1, scry2, scrx2, scry2);
-  XDrawLine (dpy, drw, gc, scrx2, scry1, scrx2, scry2);
-  set_colour (WINBG_LIGHT);
-  XDrawLine (dpy, drw, gc, scrx1, scry1, scrx2, scry1);
-  XDrawLine (dpy, drw, gc, scrx1, scry1, scrx1, scry2);
-  drw_mods++;
-  pop_colour ();
+    push_colour(WINBG);
+    XFillRectangle(dpy, drw, gc, scrx1 + 1, scry1 + 1, scrx2 - scrx1,
+		   scry2 - scry1);
+    set_colour(WINBG_DARK);
+    XDrawLine(dpy, drw, gc, scrx1, scry2, scrx2, scry2);
+    XDrawLine(dpy, drw, gc, scrx2, scry1, scrx2, scry2);
+    set_colour(WINBG_LIGHT);
+    XDrawLine(dpy, drw, gc, scrx1, scry1, scrx2, scry1);
+    XDrawLine(dpy, drw, gc, scrx1, scry1, scrx1, scry2);
+    drw_mods++;
+    pop_colour();
 }
 
 
@@ -933,51 +955,51 @@
  *	(thickness) is the thickness of the border in pixels.
  *	(raised) is zero for depressed, non-zero for raised.
  */
-void draw_box_border (int x, int y, int width, int height,
-  int thickness, int raised)
+void draw_box_border(int x, int y, int width, int height,
+		     int thickness, int raised)
 {
-  int n;
-  XPoint points[3];
+    int n;
+    XPoint points[3];
 
-  // We want offsets, not distances
-  width--;
-  height--;
+    // We want offsets, not distances
+    width--;
+    height--;
 
-  // Draw the right and bottom edges
-  push_colour (raised ? WINBG_DARK : WINBG_LIGHT);
-  points[0].x = x + width;
-  points[0].y = y;
-  points[1].x = 0;
-  points[1].y = height;
-  points[2].x = -width;
-  points[2].y = 0;
-  for (n = 0; n < thickness; n++)
-  {
-    XDrawLines (dpy, drw, gc, points, 3, CoordModePrevious);
-    points[0].x--;
-    points[0].y++;
-    points[1].y--;
-    points[2].x++;
-  }
+    // Draw the right and bottom edges
+    push_colour(raised ? WINBG_DARK : WINBG_LIGHT);
+    points[0].x = x + width;
+    points[0].y = y;
+    points[1].x = 0;
+    points[1].y = height;
+    points[2].x = -width;
+    points[2].y = 0;
+    for (n = 0; n < thickness; n++)
+    {
+	XDrawLines(dpy, drw, gc, points, 3, CoordModePrevious);
+	points[0].x--;
+	points[0].y++;
+	points[1].y--;
+	points[2].x++;
+    }
 
-  // Draw the left and top edges
-  set_colour (raised ? WINBG_LIGHT : WINBG_DARK);
-  points[0].x = x;
-  points[0].y = y + height;
-  points[1].x = 0;
-  points[1].y = -height;
-  points[2].x = width;
-  points[2].y = 0;
-  for (n = 0; n < thickness; n++)
-  {
-    XDrawLines (dpy, drw, gc, points, 3, CoordModePrevious);
-    points[0].x++;
-    points[0].y--;
-    points[1].y++;
-    points[2].x--;
-  }
+    // Draw the left and top edges
+    set_colour(raised ? WINBG_LIGHT : WINBG_DARK);
+    points[0].x = x;
+    points[0].y = y + height;
+    points[1].x = 0;
+    points[1].y = -height;
+    points[2].x = width;
+    points[2].y = 0;
+    for (n = 0; n < thickness; n++)
+    {
+	XDrawLines(dpy, drw, gc, points, 3, CoordModePrevious);
+	points[0].x++;
+	points[0].y--;
+	points[1].y++;
+	points[2].x--;
+    }
 
-  pop_colour ();
+    pop_colour();
 }
 
 
@@ -986,20 +1008,22 @@
  *
  *	The 3D border is HOLLOW_BORDER pixels wide.
  */
-void DrawScreenBoxHollow (int scrx1, int scry1, int scrx2, int scry2, acolour_t colour)
+void DrawScreenBoxHollow(int scrx1, int scry1, int scrx2, int scry2,
+			 acolour_t colour)
 {
-  push_colour (colour);
-  XFillRectangle (dpy, drw, gc,
-      scrx1 + HOLLOW_BORDER, scry1 + HOLLOW_BORDER,
-      scrx2 + 1 - scrx1 - 2 * HOLLOW_BORDER, scry2 + 1 - scry1 - 2 * HOLLOW_BORDER);
-  set_colour (WINBG_LIGHT);
-  XDrawLine (dpy, drw, gc, scrx1, scry2, scrx2, scry2);
-  XDrawLine (dpy, drw, gc, scrx2, scry1, scrx2, scry2);
-  set_colour (WINBG_DARK);
-  XDrawLine (dpy, drw, gc, scrx1, scry1, scrx2, scry1);
-  XDrawLine (dpy, drw, gc, scrx1, scry1, scrx1, scry2);
-  drw_mods++;
-  pop_colour ();
+    push_colour(colour);
+    XFillRectangle(dpy, drw, gc,
+		   scrx1 + HOLLOW_BORDER, scry1 + HOLLOW_BORDER,
+		   scrx2 + 1 - scrx1 - 2 * HOLLOW_BORDER,
+		   scry2 + 1 - scry1 - 2 * HOLLOW_BORDER);
+    set_colour(WINBG_LIGHT);
+    XDrawLine(dpy, drw, gc, scrx1, scry2, scrx2, scry2);
+    XDrawLine(dpy, drw, gc, scrx2, scry1, scrx2, scry2);
+    set_colour(WINBG_DARK);
+    XDrawLine(dpy, drw, gc, scrx1, scry1, scrx2, scry1);
+    XDrawLine(dpy, drw, gc, scrx1, scry1, scrx1, scry2);
+    drw_mods++;
+    pop_colour();
 }
 
 
@@ -1008,19 +1032,21 @@
  *
  *	In a hollow box; max. value = 1.0
  */
-void DrawScreenMeter (int scrx1, int scry1, int scrx2, int scry2, float value)
+void DrawScreenMeter(int scrx1, int scry1, int scrx2, int scry2, float value)
 {
 #if defined Y_BGI
-  if (value < 0.0)
-    value = 0.0;
-  if (value > 1.0)
-    value = 1.0;
-  setfillstyle (1, TranslateToDoomColor (BLACK));
-  bar (scrx1 + 1 + (int) ((scrx2 - scrx1 - 2) * value), scry1 + 1, scrx2 - 1, scry2 - 1);
-  setfillstyle (1, TranslateToDoomColor (LIGHTGREEN));
-  bar (scrx1 + 1, scry1 + 1, scrx1 + 1 + (int) ((scrx2 - scrx1 - 2) * value), scry2 - 1);
+    if (value < 0.0)
+	value = 0.0;
+    if (value > 1.0)
+	value = 1.0;
+    setfillstyle(1, TranslateToDoomColor(BLACK));
+    bar(scrx1 + 1 + (int) ((scrx2 - scrx1 - 2) * value), scry1 + 1, scrx2 - 1,
+	scry2 - 1);
+    setfillstyle(1, TranslateToDoomColor(LIGHTGREEN));
+    bar(scrx1 + 1, scry1 + 1, scrx1 + 1 + (int) ((scrx2 - scrx1 - 2) * value),
+	scry2 - 1);
 #elif defined Y_X11
-  // FIXME
+    // FIXME
 #endif
 }
 
@@ -1049,30 +1075,30 @@
  *	If <msg> == NULL, no text is printed. Useful to set the
  *	coordinates for the next time.
  */
-void DrawScreenText (int scrx, int scry, const char *msg, ...)
+void DrawScreenText(int scrx, int scry, const char *msg, ...)
 {
-  char temp[120];
-  va_list args;
+    char temp[120];
+    va_list args;
 
-  // <msg> == NULL: print nothing, just set the coordinates.
-  if (msg == NULL)
-  {
-    if (scrx != -1 && scrx != -2)
+    // <msg> == NULL: print nothing, just set the coordinates.
+    if (msg == NULL)
     {
-      lastx0   = scrx;
-      lastxcur = scrx;
+	if (scrx != -1 && scrx != -2)
+	{
+	    lastx0 = scrx;
+	    lastxcur = scrx;
+	}
+	if (scry != -1 && scry != -2)
+	{
+	    lasty0 = scry;	// Note: no "+ FONTH"
+	    lastycur = scry;
+	}
+	return;
     }
-    if (scry != -1 && scry != -2)
-    {
-      lasty0   = scry;  // Note: no "+ FONTH"
-      lastycur = scry;
-    }
-    return;
-  }
 
-  va_start (args, msg);
-  y_vsnprintf (temp, sizeof temp, msg, args);
-  DrawScreenString (scrx, scry, temp);
+    va_start(args, msg);
+    y_vsnprintf(temp, sizeof temp, msg, args);
+    DrawScreenString(scrx, scry, temp);
 }
 
 
@@ -1099,69 +1125,71 @@
  *	This colour switching business was hacked in a hurry.
  *	Feel free to improve it.
  */
-void DrawScreenString (int scrx, int scry, const char *str)
+void DrawScreenString(int scrx, int scry, const char *str)
 {
-  int x; int y;
+    int x;
+    int y;
 
-  /* FIXME originally, the test was "< 0". Because it broke
-     when the screen was too small, I changed it to a more
-     specific "== -1". A quick and very dirty hack ! */
-  if (scrx == -1)
-    x = lastx0;
-  else if (scrx == -2)
-    x = lastxcur;
-  else
-    x = scrx;
-  if (scry == -1)
-    y = lasty0;
-  else if (scry == -2)
-    y = lastycur;
-  else
-    y = scry;
+    /* FIXME originally, the test was "< 0". Because it broke
+       when the screen was too small, I changed it to a more
+       specific "== -1". A quick and very dirty hack ! */
+    if (scrx == -1)
+	x = lastx0;
+    else if (scrx == -2)
+	x = lastxcur;
+    else
+	x = scrx;
+    if (scry == -1)
+	y = lasty0;
+    else if (scry == -2)
+	y = lastycur;
+    else
+	y = scry;
 
-  size_t len = strlen (str);
+    size_t len = strlen(str);
 
-  if (strchr (str, '\1') == 0)
-  {
-    XDrawString (dpy, drw, gc, x - font_xofs, y + font_yofs, str, len);
-  }
-  else
-  {
-    acolour_t save = get_colour ();
-    int xx = x;
-    len = 0;
-    for (const char *p = str; *p != '\0';)
+    if (strchr(str, '\1') == 0)
+    {
+	XDrawString(dpy, drw, gc, x - font_xofs, y + font_yofs, str, len);
+    }
+    else
     {
-      int i;
-      for (i = 0; p[i] != '\0' && p[i] != '\1' && p[i] != '\2'; i++)
-	;
-      len += i;
-      if (i > 0)
-      {
-	XDrawString (dpy, drw, gc, xx - font_xofs, y + font_yofs, p, i);
-	xx += i * FONTW;
-      }
-      if (p[i] == '\0')
-	break;
-      if (p[i] == '\1')
-	set_colour (save == WINFG_DIM ? WINLABEL_DIM : WINLABEL);
-      else if (p[i] == '\2')
-	set_colour (save);
-      i++;
-      p += i;
+	acolour_t save = get_colour();
+	int xx = x;
+	len = 0;
+	for (const char *p = str; *p != '\0';)
+	{
+	    int i;
+	    for (i = 0; p[i] != '\0' && p[i] != '\1' && p[i] != '\2'; i++)
+		;
+	    len += i;
+	    if (i > 0)
+	    {
+		XDrawString(dpy, drw, gc, xx - font_xofs, y + font_yofs, p,
+			    i);
+		xx += i * FONTW;
+	    }
+	    if (p[i] == '\0')
+		break;
+	    if (p[i] == '\1')
+		set_colour(save == WINFG_DIM ? WINLABEL_DIM : WINLABEL);
+	    else if (p[i] == '\2')
+		set_colour(save);
+	    i++;
+	    p += i;
+	}
+	set_colour(save);
     }
-    set_colour (save);
-  }
-  if (text_dot)
-    XDrawPoint (dpy, drw, gc, x, y);
-  drw_mods++;
+    if (text_dot)
+	XDrawPoint(dpy, drw, gc, x, y);
+    drw_mods++;
 
-  lastxcur = x + FONTW * len;
-  lastycur = y;
-  if (scrx != -2)
-    lastx0 = x;
-  if (scry != -2)
-    lasty0 = y + FONTH;
+    lastxcur = x + FONTW * len;
+    lastycur = y;
+    if (scrx != -2)
+	lastx0 = x;
+    if (scry != -2)
+	lasty0 = y + FONTH;
 }
 
 
@@ -1171,10 +1199,10 @@
  *	Same thing as DrawScreenText() except that the string is
  *	printed verbatim (no formatting or conversion).
  */
-void DrawScreenChar (int x, int y, char c)
+void DrawScreenChar(int x, int y, char c)
 {
-  XDrawString (dpy, drw, gc, x - font_xofs, y + font_yofs, &c, 1);
-  if (text_dot)
-    XDrawPoint (dpy, drw, gc, x, y);
-  drw_mods++;
+    XDrawString(dpy, drw, gc, x - font_xofs, y + font_yofs, &c, 1);
+    if (text_dot)
+	XDrawPoint(dpy, drw, gc, x, y);
+    drw_mods++;
 }
--- a/src/gfx.h	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/gfx.h	Sat Sep 24 14:16:04 2011 +0300
@@ -4,8 +4,8 @@
  */
 
 
-#ifndef YH_GFX  /* Prevent multiple inclusion */
-#define YH_GFX  /* Prevent multiple inclusion */
+#ifndef YH_GFX			/* Prevent multiple inclusion */
+#define YH_GFX			/* Prevent multiple inclusion */
 
 
 /* Width and height of font cell. Those figures are not meant to
@@ -38,79 +38,79 @@
 #define WIDE_VSPACING  (FONTH / 2)
 
 /* Boxes */
-#define BOX_BORDER    2	 // Offset between outer and inner edges of a 3D box
-#define NARROW_BORDER 1	 // Same thing for a shallow 3D box
-#define HOLLOW_BORDER 1	 // Same thing for a hollow box
-#define BOX_VSPACING  WIDE_VSPACING  // Vertical space between two hollow boxes
+#define BOX_BORDER    2		// Offset between outer and inner edges of a 3D box
+#define NARROW_BORDER 1		// Same thing for a shallow 3D box
+#define HOLLOW_BORDER 1		// Same thing for a hollow box
+#define BOX_VSPACING  WIDE_VSPACING	// Vertical space between two hollow boxes
 
 /* Parameters set by command line args and configuration file */
 extern const char *font_name;	// X: the name of the font to load
 				// (if NULL, use the default)
-extern Win_dim initial_window_width;// X: the name says it all
-extern Win_dim initial_window_height;// X: the name says it all
-extern int   no_pixmap;		// X: use no pixmap -- direct window output
-extern int   VideoMode;		// BGI: default video mode for VESA cards
+extern Win_dim initial_window_width;	// X: the name says it all
+extern Win_dim initial_window_height;	// X: the name says it all
+extern int no_pixmap;		// X: use no pixmap -- direct window output
+extern int VideoMode;		// BGI: default video mode for VESA cards
 
 /* Global variables */
-extern int   GfxMode;
-extern int   OrigX;		// Map X-coord of centre of screen/window
-extern int   OrigY;		// Map Y-coord of centre of screen/window
-extern int   ScrCenterX;	// Display X-coord of center of screen/window
-extern int   ScrCenterY;	// Display Y-coord of center of screen/window
+extern int GfxMode;
+extern int OrigX;		// Map X-coord of centre of screen/window
+extern int OrigY;		// Map Y-coord of centre of screen/window
+extern int ScrCenterX;		// Display X-coord of center of screen/window
+extern int ScrCenterY;		// Display Y-coord of center of screen/window
 typedef unsigned long xpv_t;	// The type of a pixel value in X's opinion
 #ifdef X_PROTOCOL
 extern Display *dpy;
-extern int      scn;
+extern int scn;
 extern Colormap cmap;		// The X colormap
-extern Window   win;
+extern Window win;
 extern Drawable drw;
-extern GC       gc;
-extern Visual  *win_vis;	// The visual for win
-extern int      win_depth;	// The depth of win in bits
-extern int      win_bpp;	// The depth of win in bytes
-extern int	x_server_big_endian;	// Is the X server big-endian ?
-extern int      ximage_bpp;	// Number of bytes per pixels in XImages
-extern int      ximage_quantum;	// Pad XImage lines to a mult of that many B.
-#endif  // ifdef X_PROTOCOL
-extern int	text_dot;     // DrawScreenText()/DrawScreenString() debug flag
+extern GC gc;
+extern Visual *win_vis;		// The visual for win
+extern int win_depth;		// The depth of win in bits
+extern int win_bpp;		// The depth of win in bytes
+extern int x_server_big_endian;	// Is the X server big-endian ?
+extern int ximage_bpp;		// Number of bytes per pixels in XImages
+extern int ximage_quantum;	// Pad XImage lines to a mult of that many B.
+#endif // ifdef X_PROTOCOL
+extern int text_dot;		// DrawScreenText()/DrawScreenString() debug flag
 
 /* gfx.cc */
-int InitGfx (void);
-void TermGfx (void);
-void SetWindowSize (int width, int height);
-void ClearScreen (void);
-void update_display ();
-void force_window_not_pixmap ();
-void SetLineThickness (int thick);
-void SetDrawingMode (int _xor);
-void DrawMapCircle (int, int, int);
-void DrawMapLine (int mapx1, int mapy1, int mapx2, int mapy2);
-void DrawMapVector (int, int, int, int);
-void DrawMapArrow (int, int, unsigned);
-void DrawScreenLine (int, int, int, int);
-void DrawScreenRect (int x, int y, int width, int height);
-void DrawScreenBox (int, int, int, int);
-void DrawScreenBoxwh (int scrx0, int scry0, int width, int height);
-void DrawScreenBox3D (int, int, int, int);
-void DrawScreenBox3DShallow (int, int, int, int);
-void DrawScreenBoxHollow (int x0, int y0, int x1, int y1, acolour_t colour);
-void draw_box_border (int x, int y, int width, int height,
-   int thickness, int raised);
-void DrawScreenText (int, int, const char *, ...);
-void DrawScreenString (int, int, const char *);
-void DrawScreenChar (int x, int y, char c);
-void DrawScreenMeter (int, int, int, int, float);
-void DrawScreenLineLen (int x, int y, int width, int height);
-int TranslateToDoomColor (int);
+int InitGfx(void);
+void TermGfx(void);
+void SetWindowSize(int width, int height);
+void ClearScreen(void);
+void update_display();
+void force_window_not_pixmap();
+void SetLineThickness(int thick);
+void SetDrawingMode(int _xor);
+void DrawMapCircle(int, int, int);
+void DrawMapLine(int mapx1, int mapy1, int mapx2, int mapy2);
+void DrawMapVector(int, int, int, int);
+void DrawMapArrow(int, int, unsigned);
+void DrawScreenLine(int, int, int, int);
+void DrawScreenRect(int x, int y, int width, int height);
+void DrawScreenBox(int, int, int, int);
+void DrawScreenBoxwh(int scrx0, int scry0, int width, int height);
+void DrawScreenBox3D(int, int, int, int);
+void DrawScreenBox3DShallow(int, int, int, int);
+void DrawScreenBoxHollow(int x0, int y0, int x1, int y1, acolour_t colour);
+void draw_box_border(int x, int y, int width, int height,
+		     int thickness, int raised);
+void DrawScreenText(int, int, const char *, ...);
+void DrawScreenString(int, int, const char *);
+void DrawScreenChar(int x, int y, char c);
+void DrawScreenMeter(int, int, int, int, float);
+void DrawScreenLineLen(int x, int y, int width, int height);
+int TranslateToDoomColor(int);
 #ifdef PCOLOUR_NONE
-void set_pcolour (pcolour_t colour);
+void set_pcolour(pcolour_t colour);
 #endif
-acolour_t get_colour ();
-void set_colour (acolour_t);
-void push_colour (acolour_t colour);
-void pop_colour (void);
-void draw_point (int x, int y);
-void draw_map_point (int mapx, int mapy);
+acolour_t get_colour();
+void set_colour(acolour_t);
+void push_colour(acolour_t colour);
+void pop_colour(void);
+void draw_point(int x, int y);
+void draw_map_point(int mapx, int mapy);
 
 
-#endif  /* DO NOT ADD ANYTHING AFTER THIS LINE */
+#endif /* DO NOT ADD ANYTHING AFTER THIS LINE */
--- a/src/gfx3.cc	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/gfx3.cc	Sat Sep 24 14:16:04 2011 +0300
@@ -41,19 +41,19 @@
  *	Grab a rectangle from the window or screen into an
  *	Rgbbmp, in a portable fashion.
  */
-void window_to_rgbbmp (int x, int y, int width, int height, Rgbbmp &b)
+void window_to_rgbbmp(int x, int y, int width, int height, Rgbbmp & b)
 {
-  b.resize (width, height);
-  // FIXME
-  for (int y = 0; y < b.height (); y++)
-    for (int x = 0; x < b.width (); x++)
-      b.set_r (x, y, 255 * (b.height () - y) / b.height ());
-  for (int y = 0; y < b.height (); y++)
-    for (int x = 0; x < b.width (); x++)
-      b.set_g (x, y, 255 * (b.width () - x) / b.width ());
-  for (int y = 0; y < b.height (); y++)
-    for (int x = 0; x < b.width (); x++)
-      b.set_b (x, y, 255 * (x + y) / (b.width () + b.height ()));
+    b.resize(width, height);
+    // FIXME
+    for (int y = 0; y < b.height(); y++)
+	for (int x = 0; x < b.width(); x++)
+	    b.set_r(x, y, 255 * (b.height() - y) / b.height());
+    for (int y = 0; y < b.height(); y++)
+	for (int x = 0; x < b.width(); x++)
+	    b.set_g(x, y, 255 * (b.width() - x) / b.width());
+    for (int y = 0; y < b.height(); y++)
+	for (int x = 0; x < b.width(); x++)
+	    b.set_b(x, y, 255 * (x + y) / (b.width() + b.height()));
 }
 
 
@@ -61,37 +61,34 @@
  *	rgbbmp_to_rawppm
  *	Return 0 on success, non-zero on failure.
  */
-int rgbbmp_to_rawppm (const Rgbbmp &b, const char *file_name)
+int rgbbmp_to_rawppm(const Rgbbmp & b, const char *file_name)
 {
-  FILE *fd;
-  fd = fopen (file_name, "wb");
-  if (fd == 0)
-  {
-    fflush (stdout);
-    fprintf (stderr, "Can't open \"%s\" for writing (%s)\n",
-	file_name, strerror (errno));
-    fflush (stderr);
-    return 1;
-  }
-  fprintf (fd,	"P6\n"
-		"# Created by Yadex %s\n"
-		"%d %d\n"
-		"255\n", yadex_version, b.width (), b.height ());
-  for (int y = 0; y < b.height (); y++)
-    for (int x = 0; x < b.width (); x++)
+    FILE *fd;
+    fd = fopen(file_name, "wb");
+    if (fd == 0)
     {
-      putc (b.get_r (x, y), fd);
-      putc (b.get_g (x, y), fd);
-      putc (b.get_b (x, y), fd);
+	fflush(stdout);
+	fprintf(stderr, "Can't open \"%s\" for writing (%s)\n",
+		file_name, strerror(errno));
+	fflush(stderr);
+	return 1;
     }
-  if (fclose (fd))
-  {
-    fflush (stdout);
-    fprintf (stderr, "Write error in \"%s\"\n", file_name);
-    fflush (stderr);
-    return 1;
-  }
-  return 0;
+    fprintf(fd, "P6\n"
+	    "# Created by Yadex %s\n"
+	    "%d %d\n" "255\n", yadex_version, b.width(), b.height());
+    for (int y = 0; y < b.height(); y++)
+	for (int x = 0; x < b.width(); x++)
+	{
+	    putc(b.get_r(x, y), fd);
+	    putc(b.get_g(x, y), fd);
+	    putc(b.get_b(x, y), fd);
+	}
+    if (fclose(fd))
+    {
+	fflush(stdout);
+	fprintf(stderr, "Write error in \"%s\"\n", file_name);
+	fflush(stderr);
+	return 1;
+    }
+    return 0;
 }
-
-
--- a/src/gfx3.h	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/gfx3.h	Sat Sep 24 14:16:04 2011 +0300
@@ -7,7 +7,5 @@
 #include "rgbbmp.h"
 
 
-void window_to_rgbbmp (int x, int y, int width, int height, Rgbbmp &b);
-int rgbbmp_to_rawppm (const Rgbbmp &b, const char *file_name);
-
-
+void window_to_rgbbmp(int x, int y, int width, int height, Rgbbmp & b);
+int rgbbmp_to_rawppm(const Rgbbmp & b, const char *file_name);
--- a/src/gotoobj.cc	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/gotoobj.cc	Sat Sep 24 14:16:04 2011 +0300
@@ -41,16 +41,16 @@
  *	Change the view so that the map coordinates (xpos, ypos)
  *	appear at the centre of the window
  */
-void CenterMapAroundCoords (int xpos, int ypos)
+void CenterMapAroundCoords(int xpos, int ypos)
 {
-OrigX = xpos;
-OrigY = ypos;
+    OrigX = xpos;
+    OrigY = ypos;
 /* AYM 1998-09-20 This is a DOS-ism. IIRC, the ICCCM says an
    application program should generally not mess with the
    pointer. */
 #if 0
-is.x = ScrCenterX;
-is.y = ScrCenterY;
+    is.x = ScrCenterX;
+    is.y = ScrCenterY;
 #endif
 }
 
@@ -60,10 +60,10 @@
  *	Change the view so that the map coordinates (xpos, ypos)
  *	appear under the pointer
  */
-void focus_on_map_coords (int x, int y)
+void focus_on_map_coords(int x, int y)
 {
-OrigX = x - (MAPX (is.x) - OrigX);
-OrigY = y - (MAPY (is.y) - OrigY);
+    OrigX = x - (MAPX(is.x) - OrigX);
+    OrigY = y - (MAPY(is.y) - OrigY);
 }
 
 
@@ -71,11 +71,11 @@
  *	sector_under_pointer
  *	Convenience function
  */
-inline int sector_under_pointer ()
+inline int sector_under_pointer()
 {
-Objid o;
-GetCurObject (o, OBJ_SECTORS, MAPX (is.x), MAPY (is.y));
-return o.num;
+    Objid o;
+    GetCurObject(o, OBJ_SECTORS, MAPX(is.x), MAPY(is.y));
+    return o.num;
 }
 
 
@@ -83,16 +83,16 @@
   centre the map around the object and zoom in if necessary
 */
 
-void GoToObject (const Objid& objid) /* SWAP! */
+void GoToObject(const Objid & objid)	/* SWAP! */
 {
-int   xpos, ypos;
-int   xpos2, ypos2;
-int   sd1, sd2;
-float oldscale;
+    int xpos, ypos;
+    int xpos2, ypos2;
+    int sd1, sd2;
+    float oldscale;
 
-GetObjectCoords (objid.type, objid.num, &xpos, &ypos);
-focus_on_map_coords (xpos, ypos);
-oldscale = Scale;
+    GetObjectCoords(objid.type, objid.num, &xpos, &ypos);
+    focus_on_map_coords(xpos, ypos);
+    oldscale = Scale;
 
 /* I ifdef'd out this block because the only thing it really
    does is (uselessly) messing the zoom factor up when there are
@@ -100,14 +100,14 @@
    highest-numbered (and therefore hidden) one. AYM 1999-07-26 */
 #if 0
 /* zoom in until the object can be selected */
-while (Scale < 8.0
-   && GetCurObject (objid.type, MAPX (is.x), MAPY (is.y)) != objid.num)
-   {
-   if (Scale < 1.0)
-      Scale = 1.0 / ((1.0 / Scale) - 1.0);
-   else
-      Scale = Scale * 2.0;
-   }
+    while (Scale < 8.0
+	   && GetCurObject(objid.type, MAPX(is.x), MAPY(is.y)) != objid.num)
+    {
+	if (Scale < 1.0)
+	    Scale = 1.0 / ((1.0 / Scale) - 1.0);
+	else
+	    Scale = Scale * 2.0;
+    }
 #endif
 
 /* Special case for sectors: if a sector contains other sectors,
@@ -121,30 +121,27 @@
    most well-constituted sectors. It does not work so well for
    unclosed sectors, though (but it's partly GetCurObject()'s
    fault). */
-if (objid.type == OBJ_SECTORS && sector_under_pointer () != objid.num)
-   {
-   /* restore the Scale */
-   Scale = oldscale;
-   for (int n = 0; n < NumLineDefs; n++)
-      {
-      sd1 = LineDefs[n].sidedef1;
-      sd2 = LineDefs[n].sidedef2;
-      if (sd1 >= 0 && SideDefs[sd1].sector == objid.num
-	|| sd2 >= 0 && SideDefs[sd2].sector == objid.num)
-	 {
-	 GetObjectCoords (OBJ_LINEDEFS, n, &xpos2, &ypos2);
-	 int d = ComputeDist (abs (xpos - xpos2), abs (ypos - ypos2)) / 7;
-	 if (d <= 1)
-	   d = 2;
-	 xpos = xpos2 + (xpos - xpos2) / d;
-	 ypos = ypos2 + (ypos - ypos2) / d;
-	 focus_on_map_coords (xpos, ypos);
-	 if (sector_under_pointer () == objid.num)
-	    break;
-	 }
-      }
-   }
+    if (objid.type == OBJ_SECTORS && sector_under_pointer() != objid.num)
+    {
+	/* restore the Scale */
+	Scale = oldscale;
+	for (int n = 0; n < NumLineDefs; n++)
+	{
+	    sd1 = LineDefs[n].sidedef1;
+	    sd2 = LineDefs[n].sidedef2;
+	    if (sd1 >= 0 && SideDefs[sd1].sector == objid.num
+		|| sd2 >= 0 && SideDefs[sd2].sector == objid.num)
+	    {
+		GetObjectCoords(OBJ_LINEDEFS, n, &xpos2, &ypos2);
+		int d = ComputeDist(abs(xpos - xpos2), abs(ypos - ypos2)) / 7;
+		if (d <= 1)
+		    d = 2;
+		xpos = xpos2 + (xpos - xpos2) / d;
+		ypos = ypos2 + (ypos - ypos2) / d;
+		focus_on_map_coords(xpos, ypos);
+		if (sector_under_pointer() == objid.num)
+		    break;
+	    }
+	}
+    }
 }
-
-
-
--- a/src/gotoobj.h	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/gotoobj.h	Sat Sep 24 14:16:04 2011 +0300
@@ -7,6 +7,5 @@
 class Objid;
 
 
-void CenterMapAroundCoords (int, int);
-void GoToObject (const Objid& objid); /* SWAP! */
-
+void CenterMapAroundCoords(int, int);
+void GoToObject(const Objid & objid);	/* SWAP! */
--- a/src/help1.cc	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/help1.cc	Sat Sep 24 14:16:04 2011 +0300
@@ -37,11 +37,12 @@
  *	Return a static string containing
  *	the name and version number of Yadex.
  */
-const char *what ()
+const char *what()
 {
-static char buf[40];
-y_snprintf (buf, sizeof buf, "Yadex %s (%s)", yadex_version, yadex_source_date);
-return buf;
+    static char buf[40];
+    y_snprintf(buf, sizeof buf, "Yadex %s (%s)", yadex_version,
+	       yadex_source_date);
+    return buf;
 }
 
 
@@ -49,16 +50,16 @@
  *	print_usage
  *	Print the program usage.
  */
-void print_usage (FILE *fd)
+void print_usage(FILE * fd)
 {
-fprintf (fd, "%s\n", what ());
-fprintf (fd, "Usage: yadex [options] [<pwad_file> ...]\n");
-fprintf (fd, "Options:\n");
-dump_command_line_options (fd);
-fprintf (fd, " %-33sSame as -?\n", "--help");
-fprintf (fd, " %-33sPrint version and exit\n", "--version");
-fprintf (fd, "Put a \"+\" instead of a \"-\" before boolean options"
-             " to reverse their effect.\n");
+    fprintf(fd, "%s\n", what());
+    fprintf(fd, "Usage: yadex [options] [<pwad_file> ...]\n");
+    fprintf(fd, "Options:\n");
+    dump_command_line_options(fd);
+    fprintf(fd, " %-33sSame as -?\n", "--help");
+    fprintf(fd, " %-33sPrint version and exit\n", "--version");
+    fprintf(fd, "Put a \"+\" instead of a \"-\" before boolean options"
+	    " to reverse their effect.\n");
 }
 
 
@@ -66,51 +67,60 @@
  *	print_welcome
  *	Print the welcome message
  */
-void print_welcome (FILE *fd)
+void print_welcome(FILE * fd)
 {
 #ifdef OLD_MESSAGE
-fprintf (fd, "\n");
-fprintf (fd, "*----------------------------------------------------------------------------*\n");
-fprintf (fd, "| Welcome to DEU!  This is a poweful utility and, like all good tools, it    |\n");
-fprintf (fd, "| comes with its user's manual.  Please print and read DEU.TXT if you want   |\n");
-fprintf (fd, "| to discover all the features of this program.  If you are new to DEU, the  |\n");
-fprintf (fd, "| tutorial will show you how to build your first level.                      |\n");
-fprintf (fd, "|                                                                            |\n");
-fprintf (fd, "| If you are an experienced DEU user and want to know what has changed since |\n");
-fprintf (fd, "| the last version, you should read the revision history in README.1ST.      |\n");
-fprintf (fd, "|                                                                            |\n");
-fprintf (fd, "| And if you have lots of suggestions for improvements, bug reports, or even |\n");
-fprintf (fd, "| complaints about this program, be sure to read README.1ST first.           |\n");
-fprintf (fd, "| Hint: you can easily disable this message.  Read the docs carefully...     |\n");
-fprintf (fd, "*----------------------------------------------------------------------------*\n");
+    fprintf(fd, "\n");
+    fprintf(fd,
+	    "*----------------------------------------------------------------------------*\n");
+    fprintf(fd,
+	    "| Welcome to DEU!  This is a poweful utility and, like all good tools, it    |\n");
+    fprintf(fd,
+	    "| comes with its user's manual.  Please print and read DEU.TXT if you want   |\n");
+    fprintf(fd,
+	    "| to discover all the features of this program.  If you are new to DEU, the  |\n");
+    fprintf(fd,
+	    "| tutorial will show you how to build your first level.                      |\n");
+    fprintf(fd,
+	    "|                                                                            |\n");
+    fprintf(fd,
+	    "| If you are an experienced DEU user and want to know what has changed since |\n");
+    fprintf(fd,
+	    "| the last version, you should read the revision history in README.1ST.      |\n");
+    fprintf(fd,
+	    "|                                                                            |\n");
+    fprintf(fd,
+	    "| And if you have lots of suggestions for improvements, bug reports, or even |\n");
+    fprintf(fd,
+	    "| complaints about this program, be sure to read README.1ST first.           |\n");
+    fprintf(fd,
+	    "| Hint: you can easily disable this message.  Read the docs carefully...     |\n");
+    fprintf(fd,
+	    "*----------------------------------------------------------------------------*\n");
 #else
 
-fprintf (fd, "\n"
-                "** Welcome to Yadex. Glad you've made it so far. :-)\n");
+    fprintf(fd, "\n"
+	    "** Welcome to Yadex. Glad you've made it so far. :-)\n");
 #if defined Y_ALPHA
-fprintf (fd, "**\n"
-		"** This is an alpha version. Expect it to have bugs. Do\n"
-		"** yourself a favour and make backup copies of your data !\n"
-		"**\n");
+    fprintf(fd, "**\n"
+	    "** This is an alpha version. Expect it to have bugs. Do\n"
+	    "** yourself a favour and make backup copies of your data !\n"
+	    "**\n");
 #elif defined Y_BETA
-fprintf (fd, "**\n"
-		"** This is a beta version. It is believed to be reasonably\n"
-		"** stable but it's been given only limited testing. So do\n"
-		"** yourself a favour and make backup copies of your data.\n"
-		"**\n");
+    fprintf(fd, "**\n"
+	    "** This is a beta version. It is believed to be reasonably\n"
+	    "** stable but it's been given only limited testing. So do\n"
+	    "** yourself a favour and make backup copies of your data.\n"
+	    "**\n");
 #else
-fprintf (fd, "**\n"
-		"** This version is believed to be stable but you never\n"
-		"** know so make backup copies of your data anyway.\n"
-		"**\n");
+    fprintf(fd, "**\n"
+	    "** This version is believed to be stable but you never\n"
+	    "** know so make backup copies of your data anyway.\n" "**\n");
 #endif
-fprintf (fd, "** Yadex is work in progress. Subscribe to yadex-announce\n");
-fprintf (fd, "** or keep an eye on the web page.\n");
-fprintf (fd, "** To edit an existing level, type \"e <level_name>\".\n");
-fprintf (fd, "** To create a new level, type \"c\".\n"
-                "\n");
+    fprintf(fd,
+	    "** Yadex is work in progress. Subscribe to yadex-announce\n");
+    fprintf(fd, "** or keep an eye on the web page.\n");
+    fprintf(fd, "** To edit an existing level, type \"e <level_name>\".\n");
+    fprintf(fd, "** To create a new level, type \"c\".\n" "\n");
 #endif
 }
-
-
-
--- a/src/help1.h	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/help1.h	Sat Sep 24 14:16:04 2011 +0300
@@ -4,8 +4,6 @@
  */
 
 
-const char *what ();
-void print_usage (FILE *fd);
-void print_welcome (FILE *fd);
-
-
+const char *what();
+void print_usage(FILE * fd);
+void print_welcome(FILE * fd);
--- a/src/help2.cc	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/help2.cc	Sat Sep 24 14:16:04 2011 +0300
@@ -30,7 +30,7 @@
 #include "yadex.h"
 #include "credits.h"
 #include "gfx.h"
-#include "help1.h"  // what()
+#include "help1.h"		// what()
 #include "help2.h"
 
 
@@ -38,79 +38,77 @@
    display the help screen
  */
 
-static const char *help_text[] =
-{
-  "             Keyboard :",
-  "Esc/q Quit                      Pgup  Scroll up",
-  "                                Pgdn  Scroll down",
-  "Tab   Next mode                 Home  Scroll left",
-  "ShiftTab Previous mode          End   Scroll right",
-  "l     Linedefs & sidedefs mode  '     Go to centre of map",
-  "s     Sectors mode              `     Show whole map",
-  "t     Things mode               n,>   Jump to next object",
-  "v     Vertices mode             p,<   Jump to previous object",
-  "&     Show/hide object numbers  j,#   Jump to object #N",
-  "%%     Show/hide sprites",
-  "                                +/-   Zoom in/out",
-  "Ins   Insert a new object       g/G   Decr./incr. the grid step",
-  "Del   Delete the object(s)      h     Hide/show the grid",
-  "Retn  Edit object properties    H     Reset grid step to the max",
-  "x/w   Spin things cw/ccw        z     Lock the grid step",
-  "x     Split linedefs            y     Snap to grid on/off",
-  "w     Split linedefs & sector   Space Toggle extra zoom",
-  "a     Set things/ld flags",
-  "b     Toggle things/ld flags    e     Select linedefs in path",
-  "c     Clear things/ld flags     E     Select 1s linedefs in path",
-  "F8    Misc. operations",
-  "F9    Insert compound object    F5    Preferences",
-  "                                F10   Checks",
-  "             Mouse :",
-  "- Clicking on an object with the left button selects it (and",
-  "  unselects everything else unless [Ctrl] is pressed).",
-  "- Clicking on an already selected object with the left button with",
-  "  [Ctrl] pressed unselects it.",
-  "- Double clicking on an object allows to change its properties.",
-  "- You can also drag objects with the left button.",
-  "- Clicking on an empty space with the left button and moving draws",
-  "  a rectangular selection box. Releasing the button selects",
-  "  everything in that box (and unselects everything else unless",
-  "  [Ctrl] is pressed).",
-  "- Wheel or buttons 4 and 5: zoom in and out",
-  NULL
+static const char *help_text[] = {
+    "             Keyboard :",
+    "Esc/q Quit                      Pgup  Scroll up",
+    "                                Pgdn  Scroll down",
+    "Tab   Next mode                 Home  Scroll left",
+    "ShiftTab Previous mode          End   Scroll right",
+    "l     Linedefs & sidedefs mode  '     Go to centre of map",
+    "s     Sectors mode              `     Show whole map",
+    "t     Things mode               n,>   Jump to next object",
+    "v     Vertices mode             p,<   Jump to previous object",
+    "&     Show/hide object numbers  j,#   Jump to object #N",
+    "%%     Show/hide sprites",
+    "                                +/-   Zoom in/out",
+    "Ins   Insert a new object       g/G   Decr./incr. the grid step",
+    "Del   Delete the object(s)      h     Hide/show the grid",
+    "Retn  Edit object properties    H     Reset grid step to the max",
+    "x/w   Spin things cw/ccw        z     Lock the grid step",
+    "x     Split linedefs            y     Snap to grid on/off",
+    "w     Split linedefs & sector   Space Toggle extra zoom",
+    "a     Set things/ld flags",
+    "b     Toggle things/ld flags    e     Select linedefs in path",
+    "c     Clear things/ld flags     E     Select 1s linedefs in path",
+    "F8    Misc. operations",
+    "F9    Insert compound object    F5    Preferences",
+    "                                F10   Checks",
+    "             Mouse :",
+    "- Clicking on an object with the left button selects it (and",
+    "  unselects everything else unless [Ctrl] is pressed).",
+    "- Clicking on an already selected object with the left button with",
+    "  [Ctrl] pressed unselects it.",
+    "- Double clicking on an object allows to change its properties.",
+    "- You can also drag objects with the left button.",
+    "- Clicking on an empty space with the left button and moving draws",
+    "  a rectangular selection box. Releasing the button selects",
+    "  everything in that box (and unselects everything else unless",
+    "  [Ctrl] is pressed).",
+    "- Wheel or buttons 4 and 5: zoom in and out",
+    NULL
 };
 
-void DisplayHelp () /* SWAP! */
+void DisplayHelp()		/* SWAP! */
 {
-  int x0;
-  int y0;
-  int width;
-  int height;
-  size_t maxlen = 0;
-  int lines = 4;
+    int x0;
+    int y0;
+    int width;
+    int height;
+    size_t maxlen = 0;
+    int lines = 4;
 
-  for (const char **str = help_text; *str; str++)
-  {
-    size_t len = strlen (*str);
-    maxlen = y_max (maxlen, len);
-    lines++;
-  }
-  width  = (maxlen + 4) * FONTW + 2 * BOX_BORDER;
-  height = lines * FONTH + 2 * BOX_BORDER;
-  x0 = (ScrMaxX + 1 - width) / 2;
-  y0 = (ScrMaxY + 1 - height) / 2;
-  /* put in the instructions */
-  DrawScreenBox3D (x0, y0, x0 + width - 1, y0 + height - 1);
-  set_colour (LIGHTCYAN);
-  DrawScreenText (x0 + BOX_BORDER + (width - 5 * FONTW) / 2,
-		  y0 + BOX_BORDER + FONTH / 2,
-		  "Yadex");
-  set_colour (WINFG);
-  DrawScreenText (x0 + BOX_BORDER + 2 * FONTW, y0 + BOX_BORDER + FONTH, "");
-  for (const char **str = help_text; *str; str++)
-     DrawScreenText (-1, -1, *str);
-  set_colour (WINTITLE);
-  DrawScreenText (-1, -1, "Press any key to return to the editor...");
-  get_key_or_click ();
+    for (const char **str = help_text; *str; str++)
+    {
+	size_t len = strlen(*str);
+	maxlen = y_max(maxlen, len);
+	lines++;
+    }
+    width = (maxlen + 4) * FONTW + 2 * BOX_BORDER;
+    height = lines * FONTH + 2 * BOX_BORDER;
+    x0 = (ScrMaxX + 1 - width) / 2;
+    y0 = (ScrMaxY + 1 - height) / 2;
+    /* put in the instructions */
+    DrawScreenBox3D(x0, y0, x0 + width - 1, y0 + height - 1);
+    set_colour(LIGHTCYAN);
+    DrawScreenText(x0 + BOX_BORDER + (width - 5 * FONTW) / 2,
+		   y0 + BOX_BORDER + FONTH / 2, "Yadex");
+    set_colour(WINFG);
+    DrawScreenText(x0 + BOX_BORDER + 2 * FONTW, y0 + BOX_BORDER + FONTH, "");
+    for (const char **str = help_text; *str; str++)
+	DrawScreenText(-1, -1, *str);
+    set_colour(WINTITLE);
+    DrawScreenText(-1, -1, "Press any key to return to the editor...");
+    get_key_or_click();
 }
 
 
@@ -118,57 +116,57 @@
  *	about_yadex()
  *	The name says it all.
  */
-void about_yadex ()
+void about_yadex()
 {
-  int widthc  = 57;
-  int heightc = 19;
+    int widthc = 57;
+    int heightc = 19;
 
-  for (const char *const *s = yadex_copyright; *s != 0; s++)
-  {
-    if (strlen (*s) > size_t (widthc))
-      widthc = strlen (*s);
-    heightc++;
-  }
-  int width   = 2 * BOX_BORDER + 2 * WIDE_HSPACING + widthc * FONTW;
-  int height  = 2 * BOX_BORDER + 2 * WIDE_VSPACING + heightc * FONTH;
-  int x0 = (ScrMaxX + 1 - width) / 2;
-  int y0 = (ScrMaxY + 1 - height) / 2;
+    for (const char *const *s = yadex_copyright; *s != 0; s++)
+    {
+	if (strlen(*s) > size_t(widthc))
+	    widthc = strlen(*s);
+	heightc++;
+    }
+    int width = 2 * BOX_BORDER + 2 * WIDE_HSPACING + widthc * FONTW;
+    int height = 2 * BOX_BORDER + 2 * WIDE_VSPACING + heightc * FONTH;
+    int x0 = (ScrMaxX + 1 - width) / 2;
+    int y0 = (ScrMaxY + 1 - height) / 2;
 
-  DrawScreenBox3D (x0, y0, x0 + width - 1, y0 + height - 1);
-  push_colour (WINFG);
-  push_colour (WINFG_HL);
-  DrawScreenText (x0 + BOX_BORDER + WIDE_HSPACING,
-		  y0 + BOX_BORDER + WIDE_VSPACING, what ());
-  pop_colour ();
-  DrawScreenText (-1, -1, "");
-  for (const char *const *s = yadex_copyright; *s != 0; s++)
-    DrawScreenText (-1, -1, *s);
-  DrawScreenText (-1, -1, "");
-  push_colour (WINFG_HL);
-  DrawScreenText (-1, -1, "Home page :");
-  pop_colour ();
-  DrawScreenText (-1, -1, "http://www.teaser.fr/~amajorel/yadex/");
-  DrawScreenText (-1, -1, "http://www.linuxgames.com/yadex/");
-  DrawScreenText (-1, -1, "");
-  push_colour (WINFG_HL);
-  DrawScreenText (-1, -1, "Mailing lists :");
-  pop_colour ();
-  DrawScreenText (-1, -1, "you-know-what@freelists.org");
-  DrawScreenText (-1, -1, "you-know-what-announce@freelists.org");
-  DrawScreenText (-1, -1, "To subscribe, send mail with the subject");
-  DrawScreenText (-1, -1, "\"subscribe <list_name>\" to ecartis@freelists.org.");
-  DrawScreenText (-1, -1, "");
-  push_colour (WINFG_HL);
-  DrawScreenText (-1, -1, "Maintainer :");
-  pop_colour ();
-  DrawScreenText (-1, -1, "André Majorel (http://www.teaser.fr/~amajorel/)");
-  DrawScreenText (-1, -1, "Send all email to you-know-what@freelists.org, NOT to me.");
-  DrawScreenText (-1, -1, "");
-  DrawScreenText (-1, -1, "");
-  set_colour (WINTITLE);
-  DrawScreenText (-1, -1, "Press any key to return to the editor...");
-  pop_colour ();
-  get_key_or_click ();
+    DrawScreenBox3D(x0, y0, x0 + width - 1, y0 + height - 1);
+    push_colour(WINFG);
+    push_colour(WINFG_HL);
+    DrawScreenText(x0 + BOX_BORDER + WIDE_HSPACING,
+		   y0 + BOX_BORDER + WIDE_VSPACING, what());
+    pop_colour();
+    DrawScreenText(-1, -1, "");
+    for (const char *const *s = yadex_copyright; *s != 0; s++)
+	DrawScreenText(-1, -1, *s);
+    DrawScreenText(-1, -1, "");
+    push_colour(WINFG_HL);
+    DrawScreenText(-1, -1, "Home page :");
+    pop_colour();
+    DrawScreenText(-1, -1, "http://www.teaser.fr/~amajorel/yadex/");
+    DrawScreenText(-1, -1, "http://www.linuxgames.com/yadex/");
+    DrawScreenText(-1, -1, "");
+    push_colour(WINFG_HL);
+    DrawScreenText(-1, -1, "Mailing lists :");
+    pop_colour();
+    DrawScreenText(-1, -1, "you-know-what@freelists.org");
+    DrawScreenText(-1, -1, "you-know-what-announce@freelists.org");
+    DrawScreenText(-1, -1, "To subscribe, send mail with the subject");
+    DrawScreenText(-1, -1,
+		   "\"subscribe <list_name>\" to ecartis@freelists.org.");
+    DrawScreenText(-1, -1, "");
+    push_colour(WINFG_HL);
+    DrawScreenText(-1, -1, "Maintainer :");
+    pop_colour();
+    DrawScreenText(-1, -1, "André Majorel (http://www.teaser.fr/~amajorel/)");
+    DrawScreenText(-1, -1,
+		   "Send all email to you-know-what@freelists.org, NOT to me.");
+    DrawScreenText(-1, -1, "");
+    DrawScreenText(-1, -1, "");
+    set_colour(WINTITLE);
+    DrawScreenText(-1, -1, "Press any key to return to the editor...");
+    pop_colour();
+    get_key_or_click();
 }
-
-
--- a/src/help2.h	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/help2.h	Sat Sep 24 14:16:04 2011 +0300
@@ -4,6 +4,5 @@
  */
 
 
-void DisplayHelp ();
-void about_yadex ();
-
+void DisplayHelp();
+void about_yadex();
--- a/src/highlt.cc	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/highlt.cc	Sat Sep 24 14:16:04 2011 +0300
@@ -33,30 +33,28 @@
 #include "objid.h"
 
 
-highlight_c::highlight_c (void)
+highlight_c::highlight_c(void)
 {
-obj.nil ();
-obj_disp.nil ();
+    obj.nil();
+    obj_disp.nil();
 }
 
 
-void highlight_c::draw (void)
+void highlight_c::draw(void)
 {
-if (! obj_disp () && obj ())
-   {
-   HighlightObject (obj.type, obj.num, YELLOW);
-   obj_disp = obj;
-   }
+    if (!obj_disp() && obj())
+    {
+	HighlightObject(obj.type, obj.num, YELLOW);
+	obj_disp = obj;
+    }
 }
 
 
-void highlight_c::undraw (void)
+void highlight_c::undraw(void)
 {
-if (obj_disp () && ! (obj_disp == obj))
-   {
-   HighlightObject (obj_disp.type, obj_disp.num, YELLOW);
-   obj_disp.nil ();
-   }
+    if (obj_disp() && !(obj_disp == obj))
+    {
+	HighlightObject(obj_disp.type, obj_disp.num, YELLOW);
+	obj_disp.nil();
+    }
 }
-
-
--- a/src/highlt.h	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/highlt.h	Sat Sep 24 14:16:04 2011 +0300
@@ -31,22 +31,35 @@
 #include "objid.h"
 
 
-class highlight_c : public edwidget_c
-   {
-   public :
-      highlight_c (void);
-      void set (Objid& obj) { this->obj = obj; }
+class highlight_c:public edwidget_c
+{
+    public: highlight_c(void);
+    void set(Objid & obj)
+    {
+	this->obj = obj;
+    }
 
-      /* Methods declared in edwidget */
-      void unset () { obj.nil (); }
-      void draw          ();
-      void undraw        ();
-      int can_undraw () { return 1; }  // I have the ability to undraw myself.
-      int need_to_clear () { return 0; }  // I know how to undraw myself.
-      void clear () { obj_disp.nil (); }
+    /* Methods declared in edwidget */
+    void unset()
+    {
+	obj.nil();
+    }
+    void draw();
+    void undraw();
+    int can_undraw()
+    {
+	return 1;
+    }				// I have the ability to undraw myself.
+    int need_to_clear()
+    {
+	return 0;
+    }				// I know how to undraw myself.
+    void clear()
+    {
+	obj_disp.nil();
+    }
 
-   private :
-      Objid obj;	// The object we should highlight
-      Objid obj_disp;	// The object that is really highlighted
-   };
-
+  private:
+    Objid obj;			// The object we should highlight
+    Objid obj_disp;		// The object that is really highlighted
+};
--- a/src/img.cc	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/img.cc	Sat Sep 24 14:16:04 2011 +0300
@@ -38,12 +38,22 @@
 class Img_priv
 {
   public:
-    Img_priv () { buf = 0; width = 0; height = 0; opaque = false; }
-    ~Img_priv () { if (buf != 0) delete[] buf; }
+    Img_priv()
+    {
+	buf = 0;
+	width = 0;
+	height = 0;
+	opaque = false;
+    }
+     ~Img_priv()
+    {
+	if (buf != 0)
+	    delete[]buf;
+    }
     img_pixel_t *buf;
-    img_dim_t    width;
-    img_dim_t    height;
-    bool         opaque;
+    img_dim_t width;
+    img_dim_t height;
+    bool opaque;
 };
 
 
@@ -52,9 +62,9 @@
  *
  *	The new image is a null image.
  */
-Img::Img ()
+Img::Img()
 {
-  p = new Img_priv;
+    p = new Img_priv;
 }
 
 
@@ -63,29 +73,29 @@
  *
  *	The new image is set to the specified dimensions.
  */
-Img::Img (img_dim_t width, img_dim_t height, bool opaque)
+Img::Img(img_dim_t width, img_dim_t height, bool opaque)
 {
-  p = new Img_priv;
-  resize (width, height);
-  set_opaque (opaque);
+    p = new Img_priv;
+    resize(width, height);
+    set_opaque(opaque);
 }
 
 
 /*
  *	Img::~Img - dtor
  */
-Img::~Img ()
+Img::~Img()
 {
-  delete p;
+    delete p;
 }
 
 
 /*
  *	Img::is_null - return true iff this is a null image
  */
-bool Img::is_null () const
+bool Img::is_null() const
 {
-  return p->buf == 0;
+    return p->buf == 0;
 }
 
 
@@ -94,9 +104,9 @@
  *
  *	If the image is null, return 0.
  */
-img_dim_t Img::width () const
+img_dim_t Img::width() const
 {
-  return p->width;
+    return p->width;
 }
 
 
@@ -105,9 +115,9 @@
  *
  *	If the image is null, return 0.
  */
-img_dim_t Img::height () const
+img_dim_t Img::height() const
 {
-  return p->height;
+    return p->height;
 }
 
 
@@ -116,9 +126,9 @@
  *
  *	If the image is null, return a null pointer.
  */
-const img_pixel_t *Img::buf () const
+const img_pixel_t *Img::buf() const
 {
-  return p->buf;
+    return p->buf;
 }
 
 
@@ -127,62 +137,62 @@
  *
  *	If the image is null, return a null pointer.
  */
-img_pixel_t *Img::wbuf ()
+img_pixel_t *Img::wbuf()
 {
-  return p->buf;
+    return p->buf;
 }
 
 
 /*
  *	Img::clear - clear the image
  */
-void Img::clear ()
+void Img::clear()
 {
-  if (p->buf != 0)
-    memset (p->buf, IMG_TRANSP, p->width * p->height);
+    if (p->buf != 0)
+	memset(p->buf, IMG_TRANSP, p->width * p->height);
 }
 
 
 /*
  *	Img::set_opaque - set or clear the opaque flag
  */
-void Img::set_opaque (bool opaque)
+void Img::set_opaque(bool opaque)
 {
-  p->opaque = opaque;
+    p->opaque = opaque;
 }
 
- 
+
 /*
  *	Img::resize - resize the image
  *
  *	If either dimension is zero, the image becomes a null
  *	image.
  */
-void Img::resize (img_dim_t width, img_dim_t height)
+void Img::resize(img_dim_t width, img_dim_t height)
 {
-  if (width == p->width && height == p->height)
-    return;
+    if (width == p->width && height == p->height)
+	return;
 
-  // Unallocate old buffer
-  if (p->buf != 0)
-  {
-    delete[] p->buf;
-    p->buf = 0;
-  }
+    // Unallocate old buffer
+    if (p->buf != 0)
+    {
+	delete[]p->buf;
+	p->buf = 0;
+    }
 
-  // Is it a null image ?
-  if (width == 0 || height == 0)
-  {
-    p->width  = 0;
-    p->height = 0;
-    return;
-  }
+    // Is it a null image ?
+    if (width == 0 || height == 0)
+    {
+	p->width = 0;
+	p->height = 0;
+	return;
+    }
 
-  // Allocate new buffer
-  p->width  = width;
-  p->height = height;
-  p->buf = new img_pixel_t[width * height + 10];  // Some slack
-  clear ();
+    // Allocate new buffer
+    p->width = width;
+    p->height = height;
+    p->buf = new img_pixel_t[width * height + 10];	// Some slack
+    clear();
 }
 
 
@@ -195,77 +205,76 @@
  *	- ECHILD if PLAYPAL could not be loaded
  *	- whatever fopen() or fclose() set it to
  */
-int Img::save (const char *filename) const
+int Img::save(const char *filename) const
 {
-  int rc = 0;
-  FILE *fp = 0;
+    int rc = 0;
+    FILE *fp = 0;
 
-  // Load palette 0 from PLAYPAL
-  MDirPtr dir = FindMasterDir (MasterDir, "PLAYPAL");
-  if (dir == 0)
-  {
-    errno = ECHILD;
-    return 1;
-  }
-  unsigned char *pal = new unsigned char[768];
-  dir->wadfile->seek (dir->dir.start);
-  if (dir->wadfile->error ())
-  {
-    /*warn ("%s: can't seek to %lXh\n",
-	dir->wadfile->filename, (unsigned long) ftell (dir->wadfile->fp));
-    warn ("PLAYPAL: seek error\n");*/
-    rc = 1;
-    errno = ECHILD;
-    goto byebye;
-  }
-  dir->wadfile->read_bytes (pal, 768);
-  if (dir->wadfile->error ())
-  {
-    /*warn ("%s: read error", dir->wadfile->where ());
-    warn ("PLAYPAL: read error\n");*/
-    rc = 1;
-    errno = ECHILD;
-    goto byebye;
-  }
+    // Load palette 0 from PLAYPAL
+    MDirPtr dir = FindMasterDir(MasterDir, "PLAYPAL");
+    if (dir == 0)
+    {
+	errno = ECHILD;
+	return 1;
+    }
+    unsigned char *pal = new unsigned char[768];
+    dir->wadfile->seek(dir->dir.start);
+    if (dir->wadfile->error())
+    {
+	/*warn ("%s: can't seek to %lXh\n",
+	   dir->wadfile->filename, (unsigned long) ftell (dir->wadfile->fp));
+	   warn ("PLAYPAL: seek error\n"); */
+	rc = 1;
+	errno = ECHILD;
+	goto byebye;
+    }
+    dir->wadfile->read_bytes(pal, 768);
+    if (dir->wadfile->error())
+    {
+	/*warn ("%s: read error", dir->wadfile->where ());
+	   warn ("PLAYPAL: read error\n"); */
+	rc = 1;
+	errno = ECHILD;
+	goto byebye;
+    }
 
-  // Create PPM file
-  fp = fopen (filename, "wb");
-  if (fp == NULL)
-  {
-    rc = 1;
-    goto byebye;
-  }
-  fputs ("P6\n", fp);
-  fprintf (fp, "# %s\n", what ());
-  fprintf (fp, "%d %d 255\n", p->width, p->height);
-  {
-    const img_pixel_t *pix    = p->buf;
-    const img_pixel_t *pixmax = pix + (unsigned long) p->width * p->height;
-    for (; pix < pixmax; pix++)
+    // Create PPM file
+    fp = fopen(filename, "wb");
+    if (fp == NULL)
+    {
+	rc = 1;
+	goto byebye;
+    }
+    fputs("P6\n", fp);
+    fprintf(fp, "# %s\n", what());
+    fprintf(fp, "%d %d 255\n", p->width, p->height);
     {
-      if (*pix == IMG_TRANSP && ! p->opaque)
-      {
-	putc ( 0, fp);	// DeuTex convention, rgb:0/2f/2f
-	putc (47, fp);
-	putc (47, fp);
-      }
-      else
-      {
-	putc (pal[3 * *pix    ], fp);
-	putc (pal[3 * *pix + 1], fp);
-	putc (pal[3 * *pix + 2], fp);
-      }
+	const img_pixel_t *pix = p->buf;
+	const img_pixel_t *pixmax =
+	    pix + (unsigned long) p->width * p->height;
+	for (; pix < pixmax; pix++)
+	{
+	    if (*pix == IMG_TRANSP && !p->opaque)
+	    {
+		putc(0, fp);	// DeuTex convention, rgb:0/2f/2f
+		putc(47, fp);
+		putc(47, fp);
+	    }
+	    else
+	    {
+		putc(pal[3 * *pix], fp);
+		putc(pal[3 * *pix + 1], fp);
+		putc(pal[3 * *pix + 2], fp);
+	    }
+	}
     }
-  }
-  if (ferror (fp))
-    rc = 1;
+    if (ferror(fp))
+	rc = 1;
 
-byebye:
-  if (fp != 0)
-    if (fclose (fp))
-      rc = 1;
-  delete[] pal;
-  return rc;
+  byebye:
+    if (fp != 0)
+	if (fclose(fp))
+	    rc = 1;
+    delete[]pal;
+    return rc;
 }
-
-
--- a/src/img.h	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/img.h	Sat Sep 24 14:16:04 2011 +0300
@@ -4,11 +4,11 @@
  */
 
 
-#ifndef YH_IMG  /* DO NOT INSERT ANYTHING BEFORE THIS LINE */
+#ifndef YH_IMG			/* DO NOT INSERT ANYTHING BEFORE THIS LINE */
 #define YH_IMG
 
 
-typedef u8             img_pixel_t;
+typedef u8 img_pixel_t;
 typedef unsigned short img_dim_t;
 class Img_priv;
 
@@ -21,25 +21,23 @@
 
 class Img
 {
-  public :
-    Img ();
-    Img (img_dim_t width, img_dim_t height, bool opaque);
-    ~Img ();
-    bool               is_null    () const;	// Is it a null image ?
-    img_dim_t          width      () const;	// Return the width
-    img_dim_t          height     () const;	// Return the height
-    const img_pixel_t *buf        () const;	// Return pointer on buffer
-    img_pixel_t       *wbuf       ();		// Return pointer on buffer
-    void               clear      ();
-    void               set_opaque (bool opaque);
-    void               resize     (img_dim_t width, img_dim_t height);
-    int                save       (const char *filename) const;
-    
-  private :
-    Img            (const Img&);	// Too lazy to implement it
-    Img& operator= (const Img&);	// Too lazy to implement it
+    public: Img();
+    Img(img_dim_t width, img_dim_t height, bool opaque);
+    ~Img();
+    bool is_null() const;	// Is it a null image ?
+    img_dim_t width() const;	// Return the width
+    img_dim_t height() const;	// Return the height
+    const img_pixel_t *buf() const;	// Return pointer on buffer
+    img_pixel_t *wbuf();	// Return pointer on buffer
+    void clear();
+    void set_opaque(bool opaque);
+    void resize(img_dim_t width, img_dim_t height);
+    int save(const char *filename) const;
+
+      private: Img(const Img &);	// Too lazy to implement it
+      Img & operator=(const Img &);	// Too lazy to implement it
     Img_priv *p;
 };
 
 
-#endif  /* DO NOT ADD ANYTHING AFTER THIS LINE */
+#endif /* DO NOT ADD ANYTHING AFTER THIS LINE */
--- a/src/imgscale.cc	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/imgscale.cc	Sat Sep 24 14:16:04 2011 +0300
@@ -55,62 +55,60 @@
  *	In the case of scale factors > 1, the algorithm is
  *	suboptimal.
  */
-void scale_img (const Img& img, double scale, Img& omg)
+void scale_img(const Img & img, double scale, Img & omg)
 {
-  img_dim_t iwidth  = img.width ();
-  img_dim_t owidth  = (img_dim_t) (img.width () * scale + 0.5);
-  img_dim_t oheight = (img_dim_t) (img.height () * scale + 0.5);
-  omg.resize (owidth, oheight);
-  const img_pixel_t *const ibuf = img.buf ();
-  img_pixel_t       *const obuf = omg.wbuf ();
-  if (scale <= 2.0)
-  {
-#if 0
-    img_pixel_t *orow = obuf;
-    for (int oy = 0; oy < oheight; oy++)
-    {
-      int iy = (int) (oy / scale);
-      const img_pixel_t *const irow = ibuf + iwidth * iy;
-      for (int ox = 0; ox < owidth; ox++)
-      {
-	int ix = (int) (ox / scale);
-	*orow++ = irow[ix];
-      }
-    }
-#else  // Supposedly faster ?
-    img_pixel_t *orow = obuf;
-    int *ix = new int[owidth];
-    for (int ox = 0; ox < owidth; ox++)
-      ix[ox] = (int) (ox / scale);
-    const int *const ix_end = ix + owidth;
-    for (int oy = 0; oy < oheight; oy++)
+    img_dim_t iwidth = img.width();
+    img_dim_t owidth = (img_dim_t) (img.width() * scale + 0.5);
+    img_dim_t oheight = (img_dim_t) (img.height() * scale + 0.5);
+    omg.resize(owidth, oheight);
+    const img_pixel_t *const ibuf = img.buf();
+    img_pixel_t *const obuf = omg.wbuf();
+    if (scale <= 2.0)
     {
-      int iy = (int) (oy / scale);
-      const img_pixel_t *const irow = ibuf + iwidth * iy;
-      for (const int *i = ix; i < ix_end; i++)
-	*orow++ = irow[*i];
-    }
-    delete[] ix;
+#if 0
+	img_pixel_t *orow = obuf;
+	for (int oy = 0; oy < oheight; oy++)
+	{
+	    int iy = (int) (oy / scale);
+	    const img_pixel_t *const irow = ibuf + iwidth * iy;
+	    for (int ox = 0; ox < owidth; ox++)
+	    {
+		int ix = (int) (ox / scale);
+		*orow++ = irow[ix];
+	    }
+	}
+#else // Supposedly faster ?
+	img_pixel_t *orow = obuf;
+	int *ix = new int[owidth];
+	for (int ox = 0; ox < owidth; ox++)
+	    ix[ox] = (int) (ox / scale);
+	const int *const ix_end = ix + owidth;
+	for (int oy = 0; oy < oheight; oy++)
+	{
+	    int iy = (int) (oy / scale);
+	    const img_pixel_t *const irow = ibuf + iwidth * iy;
+	    for (const int *i = ix; i < ix_end; i++)
+		*orow++ = irow[*i];
+	}
+	delete[]ix;
 #endif
-  }
-  // (Slightly) optimized version for large zoom factors.
-  else
-  {
-    size_t pixels_at_a_time = (int) (scale + 0.99999999999);
-    int *ox = new int[iwidth];
-    for (int ix = 0; ix < iwidth; ix++)
-      ox[ix] = (int) (ix * scale);
-    for (int oy = 0; oy < oheight; oy++)
+    }
+    // (Slightly) optimized version for large zoom factors.
+    else
     {
-      int iy = (int) (oy / scale);
-      const img_pixel_t *const irow = ibuf + iwidth * iy;
-      img_pixel_t       *const orow = obuf + owidth * oy;
-      for (int ix = 0; ix < iwidth; ix++)
-	memset (orow + ox[ix], irow[ix], pixels_at_a_time);
+	size_t pixels_at_a_time = (int) (scale + 0.99999999999);
+	int *ox = new int[iwidth];
+	for (int ix = 0; ix < iwidth; ix++)
+	    ox[ix] = (int) (ix * scale);
+	for (int oy = 0; oy < oheight; oy++)
+	{
+	    int iy = (int) (oy / scale);
+	    const img_pixel_t *const irow = ibuf + iwidth * iy;
+	    img_pixel_t *const orow = obuf + owidth * oy;
+	    for (int ix = 0; ix < iwidth; ix++)
+		memset(orow + ox[ix], irow[ix], pixels_at_a_time);
+	}
+	fflush(stdout);
+	delete[]ox;
     }
-    fflush (stdout);
-    delete[] ox;
-  }
 }
-
-
--- a/src/imgscale.h	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/imgscale.h	Sat Sep 24 14:16:04 2011 +0300
@@ -4,14 +4,14 @@
  */
 
 
-#ifndef YH_IMGSCALE  /* DO NOT INSERT ANYTHING BEFORE THIS LINE */
+#ifndef YH_IMGSCALE		/* DO NOT INSERT ANYTHING BEFORE THIS LINE */
 #define YH_IMGSCALE
 
 
 class Img;
 
 
-void scale_img (const Img& img, double scale, Img& omg);
+void scale_img(const Img & img, double scale, Img & omg);
 
 
-#endif  /* DO NOT ADD ANYTHING AFTER THIS LINE */
+#endif /* DO NOT ADD ANYTHING AFTER THIS LINE */
--- a/src/imgspect.cc	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/imgspect.cc	Sat Sep 24 14:16:04 2011 +0300
@@ -35,32 +35,30 @@
 /*
  *	spectrify_img - make a game image look vaguely like a spectre
  */
-void spectrify_img (Img& img)
+void spectrify_img(Img & img)
 {
-int x,y;
-u8 grey;
+    int x, y;
+    u8 grey;
 
 // FIXME this is gross
-if (! strncmp (Game, "doom", 4))
-  grey = 104;
-else if (! strcmp (Game, "heretic"))
-  grey = 8;
-else
-{
-  nf_bug ("spectrifying not defined with this game");
-  return;
-}
+    if (!strncmp(Game, "doom", 4))
+	grey = 104;
+    else if (!strcmp(Game, "heretic"))
+	grey = 8;
+    else
+    {
+	nf_bug("spectrifying not defined with this game");
+	return;
+    }
 
-img_dim_t width  = img.width ();
-img_dim_t height = img.height ();
-img_pixel_t *buf = img.wbuf ();
-for (y = 0; y < height; y++)
-   {
-   img_pixel_t *row = buf + y * width;
-   for (x = 0; x < width; x++)
-      if (row[x] != IMG_TRANSP)
-         row[x] = grey + (rand () >> 6) % 7;  // FIXME more kludgery
-   }
+    img_dim_t width = img.width();
+    img_dim_t height = img.height();
+    img_pixel_t *buf = img.wbuf();
+    for (y = 0; y < height; y++)
+    {
+	img_pixel_t *row = buf + y * width;
+	for (x = 0; x < width; x++)
+	    if (row[x] != IMG_TRANSP)
+		row[x] = grey + (rand() >> 6) % 7;	// FIXME more kludgery
+    }
 }
-
-
--- a/src/imgspect.h	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/imgspect.h	Sat Sep 24 14:16:04 2011 +0300
@@ -7,6 +7,4 @@
 class Img;
 
 
-void spectrify_img (Img& img);
-
-
+void spectrify_img(Img & img);
--- a/src/infobar.cc	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/infobar.cc	Sat Sep 24 14:16:04 2011 +0300
@@ -44,201 +44,197 @@
 #include "objid.h"
 
 
-const char infobar_c::FILE_NAME_UNSET[1] = { ' ' };  // A special pointer value 
-const char infobar_c::LEVEL_NAME_UNSET[1] = { ' ' };  // A special pointer value
+const char infobar_c::FILE_NAME_UNSET[1] = { ' ' };	// A special pointer value 
+const char infobar_c::LEVEL_NAME_UNSET[1] = { ' ' };	// A special pointer value
 
 
-infobar_c::infobar_c ()
+infobar_c::infobar_c()
 {
-visible               = 0;
-visible_disp          = 0;
-file_name             = 0;
-file_name_disp        = FILE_NAME_UNSET;
-level_name            = 0;
-level_name_disp       = LEVEL_NAME_UNSET;
-obj_type              = OBJ_NONE;
-obj_type_disp         = OBJ_NONE;
-changes               = -1;
-changes_disp          = -1;
-grid_snap             = -1;
-grid_snap_disp        = -1;
-grid_step_locked      = -1;
-grid_step_locked_disp = -1;
-scale                 = -1;
-scale_disp            = -1;
-grid_step             = -1;
-grid_step_disp        = -1;
-flags                 = 0;
+    visible = 0;
+    visible_disp = 0;
+    file_name = 0;
+    file_name_disp = FILE_NAME_UNSET;
+    level_name = 0;
+    level_name_disp = LEVEL_NAME_UNSET;
+    obj_type = OBJ_NONE;
+    obj_type_disp = OBJ_NONE;
+    changes = -1;
+    changes_disp = -1;
+    grid_snap = -1;
+    grid_snap_disp = -1;
+    grid_step_locked = -1;
+    grid_step_locked_disp = -1;
+    scale = -1;
+    scale_disp = -1;
+    grid_step = -1;
+    grid_step_disp = -1;
+    flags = 0;
 }
 
 
 
 
-void infobar_c::draw ()
+void infobar_c::draw()
 {
-int x;
-int redraw_from_scratch;
+    int x;
+    int redraw_from_scratch;
 
-x = text_x0;
+    x = text_x0;
 
-if (! visible)
-   return;
+    if (!visible)
+	return;
 
-redraw_from_scratch =
-   visible && ! visible_disp
-   || file_name_disp        != file_name
-   || level_name_disp       != level_name
-   || obj_type_disp         != obj_type
-   || changes_disp          != changes
-   || grid_snap_disp        != grid_snap
-   || grid_step_locked_disp != grid_step_locked
-   || scale_disp            != scale
-   || grid_step_disp        != grid_step;
+    redraw_from_scratch =
+	visible && !visible_disp
+	|| file_name_disp != file_name
+	|| level_name_disp != level_name
+	|| obj_type_disp != obj_type
+	|| changes_disp != changes
+	|| grid_snap_disp != grid_snap
+	|| grid_step_locked_disp != grid_step_locked
+	|| scale_disp != scale || grid_step_disp != grid_step;
 
-if (redraw_from_scratch)
-   {
-   DrawScreenBox3D (0, out_y0, ScrMaxX, ScrMaxY);
-   visible_disp = 1;
-   flags &= ~ pointer_disp_set;
-   }
+    if (redraw_from_scratch)
+    {
+	DrawScreenBox3D(0, out_y0, ScrMaxX, ScrMaxY);
+	visible_disp = 1;
+	flags &= ~pointer_disp_set;
+    }
 
-set_colour (WINFG);
+    set_colour(WINFG);
 
 // The name of the file being edited.
-{
-int chars;
-if (! file_name)
-   {
-   const char *const msg = "(New level)";
-   if (redraw_from_scratch || file_name_disp != file_name)
-      DrawScreenText (x, text_y0, msg);
-   chars = strlen (msg);
-   }
-else
-   {
-   al_fbase_t filebase;
-   al_fext_t fileext;
-   // FIXME wasteful to do it each time
-   al_fana (file_name, 0, 0, filebase, fileext);
-   if (redraw_from_scratch || file_name_disp != file_name)
-      DrawScreenText (x, text_y0, "%s%s", filebase, fileext);
-   chars = strlen (filebase) + strlen (fileext);
-   }
-x += (chars + 2) * FONTW;
-file_name_disp = file_name;
-}
+    {
+	int chars;
+	if (!file_name)
+	{
+	    const char *const msg = "(New level)";
+	    if (redraw_from_scratch || file_name_disp != file_name)
+		DrawScreenText(x, text_y0, msg);
+	    chars = strlen(msg);
+	}
+	else
+	{
+	    al_fbase_t filebase;
+	    al_fext_t fileext;
+	    // FIXME wasteful to do it each time
+	    al_fana(file_name, 0, 0, filebase, fileext);
+	    if (redraw_from_scratch || file_name_disp != file_name)
+		DrawScreenText(x, text_y0, "%s%s", filebase, fileext);
+	    chars = strlen(filebase) + strlen(fileext);
+	}
+	x += (chars + 2) * FONTW;
+	file_name_disp = file_name;
+    }
 
 // The name of the level being edited.
-{
-int chars;
-if (! level_name)
-   {
-   const char *const msg = "(n/s)";
-   if (redraw_from_scratch || level_name_disp != level_name)
-      DrawScreenText (x, text_y0, msg);
-   chars = strlen (msg);
-   }
-else
-   {
-   if (redraw_from_scratch || level_name_disp != level_name)
-      DrawScreenText (x, text_y0, "%.5s", level_name);
-   chars = strlen (level_name);
-   }
-x += (chars + 2) * FONTW;
-level_name_disp = level_name;
-}
+    {
+	int chars;
+	if (!level_name)
+	{
+	    const char *const msg = "(n/s)";
+	    if (redraw_from_scratch || level_name_disp != level_name)
+		DrawScreenText(x, text_y0, msg);
+	    chars = strlen(msg);
+	}
+	else
+	{
+	    if (redraw_from_scratch || level_name_disp != level_name)
+		DrawScreenText(x, text_y0, "%.5s", level_name);
+	    chars = strlen(level_name);
+	}
+	x += (chars + 2) * FONTW;
+	level_name_disp = level_name;
+    }
 
 // Type of objects being edited.
-if (redraw_from_scratch || obj_type_disp != obj_type)
-   {
-   DrawScreenText (x, text_y0, "%s", GetEditModeName (obj_type));
-   obj_type_disp = obj_type;
-   }
-x += 10 * FONTW;
+    if (redraw_from_scratch || obj_type_disp != obj_type)
+    {
+	DrawScreenText(x, text_y0, "%s", GetEditModeName(obj_type));
+	obj_type_disp = obj_type;
+    }
+    x += 10 * FONTW;
 
 // Any changes made ?
-if (redraw_from_scratch || changes_disp != changes)
-   {
-   DrawScreenText (x, text_y0, changes > 1 ? "**" : (changes ? "*" : ""));
-   changes_disp = changes;
-   }
-x += 4 * FONTW;
+    if (redraw_from_scratch || changes_disp != changes)
+    {
+	DrawScreenText(x, text_y0, changes > 1 ? "**" : (changes ? "*" : ""));
+	changes_disp = changes;
+    }
+    x += 4 * FONTW;
 
 // scale
-if (redraw_from_scratch || scale_disp != scale)
-   {
+    if (redraw_from_scratch || scale_disp != scale)
+    {
 #ifdef OLD
-   if (Scale < 1.0)
-      DrawScreenText (x, text_y0, "Scale: 1/%d", (int) (1.0 / Scale + 0.5));
-   else
-      DrawScreenText (x, text_y0, "Scale: %d/1", (int) Scale);
+	if (Scale < 1.0)
+	    DrawScreenText(x, text_y0, "Scale: 1/%d",
+			   (int) (1.0 / Scale + 0.5));
+	else
+	    DrawScreenText(x, text_y0, "Scale: %d/1", (int) Scale);
 #else
-   DrawScreenText (x, text_y0, "Scale: %d%%", (int) (Scale * 100));
+	DrawScreenText(x, text_y0, "Scale: %d%%", (int) (Scale * 100));
 #endif
-   scale_disp = scale;
-   }
-x += 13 * FONTW;
+	scale_disp = scale;
+    }
+    x += 13 * FONTW;
 
 // grid_step
-if (redraw_from_scratch || grid_step_disp != grid_step)
-   {
-   DrawScreenText (x, text_y0, "Grid: %d", grid_step);
-   grid_step_disp = grid_step;
-   }
-x += 11 * FONTW;
+    if (redraw_from_scratch || grid_step_disp != grid_step)
+    {
+	DrawScreenText(x, text_y0, "Grid: %d", grid_step);
+	grid_step_disp = grid_step;
+    }
+    x += 11 * FONTW;
 
 // grid_step_locked
-if (redraw_from_scratch || grid_step_locked_disp != grid_step_locked)
-   {
-   DrawScreenText (x, text_y0, "%s", grid_step_locked ? "Lock" : "Auto");
-   grid_step_locked_disp = grid_step_locked;
-   }
-x += 6 * FONTW;
+    if (redraw_from_scratch || grid_step_locked_disp != grid_step_locked)
+    {
+	DrawScreenText(x, text_y0, "%s", grid_step_locked ? "Lock" : "Auto");
+	grid_step_locked_disp = grid_step_locked;
+    }
+    x += 6 * FONTW;
 
 // grid_snap
-if (redraw_from_scratch || grid_snap_disp != grid_snap)
-   {
-   DrawScreenText (x, text_y0, "%s", grid_snap ? "Snap" : "Free");
-   grid_snap_disp = grid_snap;
-   }
-x += 6 * FONTW;
+    if (redraw_from_scratch || grid_snap_disp != grid_snap)
+    {
+	DrawScreenText(x, text_y0, "%s", grid_snap ? "Snap" : "Free");
+	grid_snap_disp = grid_snap;
+    }
+    x += 6 * FONTW;
 
 // The current pointer coordinates.
-if ((flags & pointer_disp_set)
-   && ! (flags & pointer_set)
-      || pointer_x_disp != pointer_x
-      || pointer_y_disp != pointer_y)
-   {
-   set_colour (WINBG);
-   DrawScreenBox (x, text_y0, x + 14 * FONTW - 1, text_y1);
-   flags &= ~ pointer_disp_set;
-   }
-if ((flags & pointer_set)
-   && ! (flags & pointer_disp_set)
-      || pointer_x_disp != pointer_x
-      || pointer_y_disp != pointer_y)
-   {
-   set_colour (WINFG);
-   /* FIXME pointer_x/y are not significant the first time. */
-   DrawScreenText (x, text_y0, "%5d, %5d", pointer_x, pointer_y);
-   pointer_x_disp = pointer_x;
-   pointer_y_disp = pointer_y;
-   flags |= pointer_disp_set;
-   }
+    if ((flags & pointer_disp_set)
+	&& !(flags & pointer_set)
+	|| pointer_x_disp != pointer_x || pointer_y_disp != pointer_y)
+    {
+	set_colour(WINBG);
+	DrawScreenBox(x, text_y0, x + 14 * FONTW - 1, text_y1);
+	flags &= ~pointer_disp_set;
+    }
+    if ((flags & pointer_set)
+	&& !(flags & pointer_disp_set)
+	|| pointer_x_disp != pointer_x || pointer_y_disp != pointer_y)
+    {
+	set_colour(WINFG);
+	/* FIXME pointer_x/y are not significant the first time. */
+	DrawScreenText(x, text_y0, "%5d, %5d", pointer_x, pointer_y);
+	pointer_x_disp = pointer_x;
+	pointer_y_disp = pointer_y;
+	flags |= pointer_disp_set;
+    }
 }
 
 
-void infobar_c::clear ()
+void infobar_c::clear()
 {
-visible_disp          = 0;
-file_name_disp        = FILE_NAME_UNSET;
-level_name_disp       = LEVEL_NAME_UNSET;
-obj_type_disp         = OBJ_NONE;
-changes_disp          = -1;
-grid_snap_disp        = -1;
-grid_step_locked_disp = -1;
-scale_disp            = -1;
-grid_step_disp        = -1;
+    visible_disp = 0;
+    file_name_disp = FILE_NAME_UNSET;
+    level_name_disp = LEVEL_NAME_UNSET;
+    obj_type_disp = OBJ_NONE;
+    changes_disp = -1;
+    grid_snap_disp = -1;
+    grid_step_locked_disp = -1;
+    scale_disp = -1;
+    grid_step_disp = -1;
 }
-
-
--- a/src/infobar.h	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/infobar.h	Sat Sep 24 14:16:04 2011 +0300
@@ -31,115 +31,171 @@
 #include "edwidget.h"
 
 
-class infobar_c : public edwidget_c
-   {
-   public :
-      infobar_c ();
+class infobar_c:public edwidget_c
+{
+    public: infobar_c();
 
-      void set_visible (int visible) { this->visible = visible; }
+    void set_visible(int visible)
+    {
+	this->visible = visible;
+    }
 
-      void set_file_name (const char *file_name)
-	 { this->file_name = file_name; }
+    void set_file_name(const char *file_name)
+    {
+	this->file_name = file_name;
+    }
 
-      void set_level_name (const char *level_name)
-	 { this->level_name = level_name; }
+    void set_level_name(const char *level_name)
+    {
+	this->level_name = level_name;
+    }
 
-      void set_obj_type  (int obj_type)  { this->obj_type = obj_type; }
-      void set_changes   (int changes)   { this->changes = changes; }
-      void set_grid_snap (int grid_snap) { this->grid_snap = grid_snap; }
+    void set_obj_type(int obj_type)
+    {
+	this->obj_type = obj_type;
+    }
+    void set_changes(int changes)
+    {
+	this->changes = changes;
+    }
+    void set_grid_snap(int grid_snap)
+    {
+	this->grid_snap = grid_snap;
+    }
 
-      void set_grid_step_locked (int grid_step_locked)
-	 { this->grid_step_locked = grid_step_locked; } 
-
-      void set_scale     (float scale)   { this->scale = scale; }
-      void set_grid_step (int grid_step) { this->grid_step = grid_step; }
+    void set_grid_step_locked(int grid_step_locked)
+    {
+	this->grid_step_locked = grid_step_locked;
+    }
 
-      void set_pointer (int x, int y)
-	 {
-	 flags |= pointer_set;
-	 pointer_x = x;
-	 pointer_y = y;
-	 }
+    void set_scale(float scale)
+    {
+	this->scale = scale;
+    }
+    void set_grid_step(int grid_step)
+    {
+	this->grid_step = grid_step;
+    }
 
-      void unset_pointer ()
-	 { flags &= ~ pointer_set; }
+    void set_pointer(int x, int y)
+    {
+	flags |= pointer_set;
+	pointer_x = x;
+	pointer_y = y;
+    }
 
-      /* Methods declared in edwidget_c */
-      void draw ();
-
-      void undraw ()
-         { } // I can't undraw myself
+    void unset_pointer()
+    {
+	flags &= ~pointer_set;
+    }
 
-      int can_undraw ()
-         { return 0; }  // I don't have the ability to undraw myself
+    /* Methods declared in edwidget_c */
+    void draw();
 
-      int  need_to_clear ()
-         { return visible_disp && ! visible; } // I can't undraw myself
+    void undraw()
+    {
+    }				// I can't undraw myself
 
-      void clear ();
+    int can_undraw()
+    {
+	return 0;
+    }				// I don't have the ability to undraw myself
 
-      int req_width ()
-         { return -1; /* Infinite */ }
+    int need_to_clear()
+    {
+	return visible_disp && !visible;
+    }				// I can't undraw myself
 
-      int req_height ()
-         { return 2 * BOX_BORDER + 2 * NARROW_VSPACING + FONTH; }
+    void clear();
 
-      void set_x0 (int x0)
-         { out_x0 = x0; text_x0 = x0 + BOX_BORDER + NARROW_HSPACING; }
+    int req_width()
+    {
+	return -1;		/* Infinite */
+    }
 
-      void set_y0 (int y0)
-         { out_y0 = y0; text_y0 = y0 + BOX_BORDER + NARROW_VSPACING; }
+    int req_height()
+    {
+	return 2 * BOX_BORDER + 2 * NARROW_VSPACING + FONTH;
+    }
 
-      void set_x1 (int x1)
-         { out_x1 = x1; text_x1 = x1 - BOX_BORDER - NARROW_HSPACING; }
-
-      void set_y1 (int y1)
-         { out_y1 = y1; text_y1 = y1 - BOX_BORDER - NARROW_VSPACING; }
+    void set_x0(int x0)
+    {
+	out_x0 = x0;
+	text_x0 = x0 + BOX_BORDER + NARROW_HSPACING;
+    }
 
-      int get_x0 () { return out_x0; }
-      int get_y0 () { return out_y0; }
-      int get_x1 () { return out_x1; }
-      int get_y1 () { return out_y1; }
+    void set_y0(int y0)
+    {
+	out_y0 = y0;
+	text_y0 = y0 + BOX_BORDER + NARROW_VSPACING;
+    }
 
-   private :
-      static const char FILE_NAME_UNSET[1];  // A special pointer value 
-      static const char LEVEL_NAME_UNSET[1];  // A special pointer value
-      static const int pointer_set      = 1;
-      static const int pointer_disp_set = 2;
+    void set_x1(int x1)
+    {
+	out_x1 = x1;
+	text_x1 = x1 - BOX_BORDER - NARROW_HSPACING;
+    }
+
+    void set_y1(int y1)
+    {
+	out_y1 = y1;
+	text_y1 = y1 - BOX_BORDER - NARROW_VSPACING;
+    }
 
-      int visible;
-      int visible_disp;
-      const char *file_name;
-      const char *file_name_disp;
-      const char *level_name;
-      const char *level_name_disp;
-      int obj_type;
-      int obj_type_disp;
-      int changes;
-      int changes_disp;
-      int grid_snap;
-      int grid_snap_disp;
-      int grid_step_locked;
-      int grid_step_locked_disp;
-      float scale;
-      float scale_disp;
-      int grid_step;
-      int grid_step_disp;
-      int pointer_x;
-      int pointer_x_disp;
-      int pointer_y;
-      int pointer_y_disp;
+    int get_x0()
+    {
+	return out_x0;
+    }
+    int get_y0()
+    {
+	return out_y0;
+    }
+    int get_x1()
+    {
+	return out_x1;
+    }
+    int get_y1()
+    {
+	return out_y1;
+    }
+
+  private:
+    static const char FILE_NAME_UNSET[1];	// A special pointer value 
+    static const char LEVEL_NAME_UNSET[1];	// A special pointer value
+    static const int pointer_set = 1;
+    static const int pointer_disp_set = 2;
 
-      int out_x0;
-      int out_y0;
-      int out_x1;
-      int out_y1;
-      int text_x0;
-      int text_y0;
-      int text_x1;
-      int text_y1;
+    int visible;
+    int visible_disp;
+    const char *file_name;
+    const char *file_name_disp;
+    const char *level_name;
+    const char *level_name_disp;
+    int obj_type;
+    int obj_type_disp;
+    int changes;
+    int changes_disp;
+    int grid_snap;
+    int grid_snap_disp;
+    int grid_step_locked;
+    int grid_step_locked_disp;
+    float scale;
+    float scale_disp;
+    int grid_step;
+    int grid_step_disp;
+    int pointer_x;
+    int pointer_x_disp;
+    int pointer_y;
+    int pointer_y_disp;
 
-      int flags;
-   };
+    int out_x0;
+    int out_y0;
+    int out_x1;
+    int out_y1;
+    int text_x0;
+    int text_y0;
+    int text_x1;
+    int text_y1;
 
-
+    int flags;
+};
--- a/src/input.cc	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/input.cc	Sat Sep 24 14:16:04 2011 +0300
@@ -30,9 +30,9 @@
 
 #include "yadex.h"
 #ifdef Y_X11
-#include <time.h>	// nanosleep ()
+#include <time.h>		// nanosleep ()
 #include <X11/Xlib.h>
-#include <X11/Xutil.h>  // XLookupString
+#include <X11/Xutil.h>		// XLookupString
 #include <X11/keysym.h>
 #include "gfx.h"
 
@@ -51,18 +51,18 @@
  *	Initialize <is>. Must be called before using <is> or calling
  *	get_input_status().
  */
-void init_input_status ()
+void init_input_status()
 {
-is.in_window   = 0;
-is.width       = -1;
-is.height      = 0;
-is.butl        = 0;
-is.butm        = 0;
-is.butr        = 0;
-is.shift       = 0;
-is.ctrl        = 0;
-is.alt         = 0;
-is.scroll_lock = 0;
+    is.in_window = 0;
+    is.width = -1;
+    is.height = 0;
+    is.butl = 0;
+    is.butm = 0;
+    is.butr = 0;
+    is.shift = 0;
+    is.ctrl = 0;
+    is.alt = 0;
+    is.scroll_lock = 0;
 }
 
 
@@ -71,45 +71,44 @@
  *	of the YK_-something codes.
  */
 typedef struct
-   {
-   KeySym ks;
-   inpev_t key;
-   } key_info_t;
-static const key_info_t key_info[] =
-   {
-   { XK_BackSpace,	YK_BACKSPACE	},
-#ifdef XK_ISO_Left_Tab  /* OpenServer 5.0 X11R5 doesn't have XK_ISO_Left_Tab */
-   { XK_ISO_Left_Tab,	YK_BACKTAB	},
+{
+    KeySym ks;
+    inpev_t key;
+} key_info_t;
+static const key_info_t key_info[] = {
+    {XK_BackSpace, YK_BACKSPACE},
+#ifdef XK_ISO_Left_Tab		/* OpenServer 5.0 X11R5 doesn't have XK_ISO_Left_Tab */
+    {XK_ISO_Left_Tab, YK_BACKTAB},
 #endif
-   { XK_Delete,		YK_DEL,		},
-   { XK_Down,		YK_DOWN,	},
-   { XK_End,		YK_END,		},
-   { XK_Escape,		YK_ESC,		},
-   { XK_F1,		YK_F1,		},
-   { XK_F2,		YK_F2,		},
-   { XK_F3,		YK_F3,		},
-   { XK_F4,		YK_F4,		},
-   { XK_F5,		YK_F5,		},
-   { XK_F6,		YK_F6,		},
-   { XK_F7,		YK_F7,		},
-   { XK_F8,		YK_F8,		},
-   { XK_F9,		YK_F9,		},
-   { XK_F10,		YK_F10,		},
-   { XK_Home,		YK_HOME,	},
-   { XK_Insert,		YK_INS,		},
-   { XK_Left,		YK_LEFT,	},
-   { XK_Linefeed,	YK_RETURN,	},
-#ifdef XK_Page_Down	/* HP-UX 10 doesn't have XK_Page_Down */
-   { XK_Page_Down,	YK_PD,		},
+    {XK_Delete, YK_DEL,},
+    {XK_Down, YK_DOWN,},
+    {XK_End, YK_END,},
+    {XK_Escape, YK_ESC,},
+    {XK_F1, YK_F1,},
+    {XK_F2, YK_F2,},
+    {XK_F3, YK_F3,},
+    {XK_F4, YK_F4,},
+    {XK_F5, YK_F5,},
+    {XK_F6, YK_F6,},
+    {XK_F7, YK_F7,},
+    {XK_F8, YK_F8,},
+    {XK_F9, YK_F9,},
+    {XK_F10, YK_F10,},
+    {XK_Home, YK_HOME,},
+    {XK_Insert, YK_INS,},
+    {XK_Left, YK_LEFT,},
+    {XK_Linefeed, YK_RETURN,},
+#ifdef XK_Page_Down		/* HP-UX 10 doesn't have XK_Page_Down */
+    {XK_Page_Down, YK_PD,},
 #endif
-#ifdef XK_Page_Up	/* HP-UX 10 doesn't have XK_Page_Up */
-   { XK_Page_Up,	YK_PU,		},
+#ifdef XK_Page_Up		/* HP-UX 10 doesn't have XK_Page_Up */
+    {XK_Page_Up, YK_PU,},
 #endif
-   { XK_Return,		YK_RETURN,	},
-   { XK_Right,		YK_RIGHT,	},
-   { XK_Tab,		YK_TAB,		},
-   { XK_Up,		YK_UP,		},
-   };
+    {XK_Return, YK_RETURN,},
+    {XK_Right, YK_RIGHT,},
+    {XK_Tab, YK_TAB,},
+    {XK_Up, YK_UP,},
+};
 
 
 /*
@@ -118,271 +117,274 @@
  *	If no event is available, waits for idle_sleep_ms ms
  *	and returns (it's used for the autoscroll feature).
  */
-void get_input_status ()
+void get_input_status()
 {
-XEvent ev;
-
-is.key = 0;
+    XEvent ev;
 
-if (! dpy)  /* Sanity check */
-   fatal_error ("get_input_status() called before XOpenDisplay()");
-if (XPending (dpy) == 0)
-   {
-   // No event ? Wait for <idle_sleep_ms> ms before polling again.
-#if defined Y_NANOSLEEP
-   struct timespec treq = { 0, 1000000ul * idle_sleep_ms };
-   struct timespec trem;
-   nanosleep (&treq, &trem);
-#elif defined Y_USLEEP
-   usleep (1000ul * idle_sleep_ms );
-#else
-   ;  // Neither nanosleep() no usleep() so be a CPU hog.
-   // FIXME: if autoscroll is turned off, could as well
-   // call XNextEvent and sleep for good.
-#endif
-   return;
-   }
-
-XNextEvent (dpy, &ev);
+    is.key = 0;
 
-switch (ev.type)
-   {
-   /* Exposure */
-   case Expose :
-#if 0
-      printf ("expose: send=%d w=%d x,y=%4d,%4d w,h=%4d,%4d c=%d\n",
-	 (int) ev.xexpose.send_event,
-	 (int) ev.xexpose.window,
-	 (int) ev.xexpose.x,
-	 (int) ev.xexpose.y,
-	 (int) ev.xexpose.width,
-	 (int) ev.xexpose.height,
-	 (int) ev.xexpose.count);
-#endif
-      if (ev.xexpose.window == win && ev.xexpose.count == 0)
-	 is.key = YE_EXPOSE;
-      break;
-
-   /* Resize */
-   case ConfigureNotify :
-#if 0
-      printf ("configure: x,y=%4d,%4d w,h=%4d,%4d\n",
-         (int) ev.xconfigure.x,
-         (int) ev.xconfigure.y,
-         (int) ev.xconfigure.width,
-         (int) ev.xconfigure.height);
+    if (!dpy)			/* Sanity check */
+	fatal_error("get_input_status() called before XOpenDisplay()");
+    if (XPending(dpy) == 0)
+    {
+	// No event ? Wait for <idle_sleep_ms> ms before polling again.
+#if defined Y_NANOSLEEP
+	struct timespec treq = { 0, 1000000ul * idle_sleep_ms };
+	struct timespec trem;
+	nanosleep(&treq, &trem);
+#elif defined Y_USLEEP
+	usleep(1000ul * idle_sleep_ms);
+#else
+	;			// Neither nanosleep() no usleep() so be a CPU hog.
+	// FIXME: if autoscroll is turned off, could as well
+	// call XNextEvent and sleep for good.
 #endif
-      if (is.width < 0 || ev.xconfigure.width != is.width
-		       || ev.xconfigure.height != is.height)
-	 {
-	 is.key    = YE_RESIZE;
-	 is.width  = ev.xconfigure.width;
-	 is.height = ev.xconfigure.height;
-	 }
-      break;
+	return;
+    }
+
+    XNextEvent(dpy, &ev);
 
-   /* Mouse motion */
-   case EnterNotify :
-      is.key       = YE_ENTER;
-      is.time      = ev.xcrossing.time;
-      is.in_window = 1;
-      // Sanity
-      if (ev.xcrossing.x < 0) nf_bug ("xcrossing.x < 0");  // Paranoia
-      if (ev.xcrossing.y < 0) nf_bug ("xcrossing.y < 0");  // Paranoia
-      is.x = ev.xcrossing.x;
-      is.y = ev.xcrossing.y;
-      break;
-   case LeaveNotify :
-      is.key       = YE_LEAVE;
-      is.time      = ev.xcrossing.time;
-      is.in_window = 0;  /* Should probably "release" buttons */
-      return;
-      break;
-   case MotionNotify :
-      is.key  = YE_MOTION;
-      is.time = ev.xmotion.time;
-      if (ev.xmotion.x < 0) nf_bug ("xmotion.x < 0");  // Paranoia
-      if (ev.xmotion.y < 0) nf_bug ("xmotion.y < 0");  // Paranoia
-      is.x = ev.xmotion.x;
-      is.y = ev.xmotion.y;
-#ifdef DEBUG
-      {
-	static bool first_time = true;
-	static int dxmin = INT_MAX;
-	static int dxmax = INT_MIN;
-	static int dymin = INT_MAX;
-	static int dymax = INT_MIN;
-	static int prevx = 0;
-	static int prevy = 0;
-	bool change = false;
-	if (! first_time)
+    switch (ev.type)
+    {
+	/* Exposure */
+    case Expose:
+#if 0
+	printf("expose: send=%d w=%d x,y=%4d,%4d w,h=%4d,%4d c=%d\n",
+	       (int) ev.xexpose.send_event,
+	       (int) ev.xexpose.window,
+	       (int) ev.xexpose.x,
+	       (int) ev.xexpose.y,
+	       (int) ev.xexpose.width,
+	       (int) ev.xexpose.height, (int) ev.xexpose.count);
+#endif
+	if (ev.xexpose.window == win && ev.xexpose.count == 0)
+	    is.key = YE_EXPOSE;
+	break;
+
+	/* Resize */
+    case ConfigureNotify:
+#if 0
+	printf("configure: x,y=%4d,%4d w,h=%4d,%4d\n",
+	       (int) ev.xconfigure.x,
+	       (int) ev.xconfigure.y,
+	       (int) ev.xconfigure.width, (int) ev.xconfigure.height);
+#endif
+	if (is.width < 0 || ev.xconfigure.width != is.width
+	    || ev.xconfigure.height != is.height)
 	{
-	  int dx = prevx - ev.xmotion.x;
-	  int dy = prevy - ev.xmotion.y;
-
-	  if (dx < dxmin)
-	  {
-	    dxmin = dx;
-	    change = true;
-	  }
-	  if (dx > dxmax)
-	  {
-	    dxmax = dx;
-	    change = true;
-	  }
-	  if (dy < dymin)
-	  {
-	    dymin = dy;
-	    change = true;
-	  }
-	  if (dy > dymax)
-	  {
-	    dymax = dy;
-	    change = true;
-	  }
+	    is.key = YE_RESIZE;
+	    is.width = ev.xconfigure.width;
+	    is.height = ev.xconfigure.height;
 	}
-	prevx = ev.xmotion.x;
-	prevy = ev.xmotion.y;
-	first_time = false;
-	if (change)
-	  printf ("Mouse: xmin=%d, xmax=%d, ymin=%d, ymax=%d\n",
-	    dxmin, dxmax, dymin, dymax);
-      }
-#endif
-      // DEBUG
-      break;
+	break;
 
-   /* Mouse buttons */
-   case ButtonPress :
-   case ButtonRelease :
-      {
-      is.time = ev.xbutton.time;
-      int press = (ev.type == ButtonPress);
-      if (ev.xbutton.button == Button1)
-	 {
-	 is.key = press ? YE_BUTL_PRESS : YE_BUTL_RELEASE;
-	 is.butl = press;
-	 }
-      else if (ev.xbutton.button == Button2)
-	 {
-	 is.key = press ? YE_BUTM_PRESS : YE_BUTM_RELEASE;
-	 is.butm = press;
-	 }
-      else if (ev.xbutton.button == Button3)
-	 {
-	 is.key = press ? YE_BUTR_PRESS : YE_BUTR_RELEASE;
-	 is.butr = press;
-	 }
-      else if (ev.xbutton.button == Button4)
-	 {
-	 is.key = press ? YE_WHEEL_UP : 0;
-	 }
-      else if (ev.xbutton.button == Button5)
-	 {
-	 is.key = press ? YE_WHEEL_DOWN : 0;
-	 }
-      break;
-      }
+	/* Mouse motion */
+    case EnterNotify:
+	is.key = YE_ENTER;
+	is.time = ev.xcrossing.time;
+	is.in_window = 1;
+	// Sanity
+	if (ev.xcrossing.x < 0)
+	    nf_bug("xcrossing.x < 0");	// Paranoia
+	if (ev.xcrossing.y < 0)
+	    nf_bug("xcrossing.y < 0");	// Paranoia
+	is.x = ev.xcrossing.x;
+	is.y = ev.xcrossing.y;
+	break;
+    case LeaveNotify:
+	is.key = YE_LEAVE;
+	is.time = ev.xcrossing.time;
+	is.in_window = 0;	/* Should probably "release" buttons */
+	return;
+	break;
+    case MotionNotify:
+	is.key = YE_MOTION;
+	is.time = ev.xmotion.time;
+	if (ev.xmotion.x < 0)
+	    nf_bug("xmotion.x < 0");	// Paranoia
+	if (ev.xmotion.y < 0)
+	    nf_bug("xmotion.y < 0");	// Paranoia
+	is.x = ev.xmotion.x;
+	is.y = ev.xmotion.y;
+#ifdef DEBUG
+	{
+	    static bool first_time = true;
+	    static int dxmin = INT_MAX;
+	    static int dxmax = INT_MIN;
+	    static int dymin = INT_MAX;
+	    static int dymax = INT_MIN;
+	    static int prevx = 0;
+	    static int prevy = 0;
+	    bool change = false;
+	    if (!first_time)
+	    {
+		int dx = prevx - ev.xmotion.x;
+		int dy = prevy - ev.xmotion.y;
 
-   /*
-    * Keyboard
-    * FIXME: need to handle NotifyKeymap event as well.
-    */
-   case KeyPress :
-   case KeyRelease :
-      {
-      KeySym ks;
-      int press;
-      unsigned char c;
-      int has_string;
-
-      is.time = ev.xkey.time;
-
-      press = (ev.type == KeyPress);
+		if (dx < dxmin)
+		{
+		    dxmin = dx;
+		    change = true;
+		}
+		if (dx > dxmax)
+		{
+		    dxmax = dx;
+		    change = true;
+		}
+		if (dy < dymin)
+		{
+		    dymin = dy;
+		    change = true;
+		}
+		if (dy > dymax)
+		{
+		    dymax = dy;
+		    change = true;
+		}
+	    }
+	    prevx = ev.xmotion.x;
+	    prevy = ev.xmotion.y;
+	    first_time = false;
+	    if (change)
+		printf("Mouse: xmin=%d, xmax=%d, ymin=%d, ymax=%d\n",
+		       dxmin, dxmax, dymin, dymax);
+	}
+#endif
+	// DEBUG
+	break;
 
-      /* Convert keycode -> keysym + char. The keysym is useful for keys
-	 such as cursor arrows that don't have an ASCII code. */
-      has_string = XLookupString ((XKeyEvent *) &ev, (char *) &c, 1, &ks, NULL);
-
-      /* The event says that Ctrl, Alt and Shift are not in the state we
-	 thought they were. Don't panic ; it's just that we missed the
-	 modifier key press/release event as it happened when we didn't
-	 have focus. Adjust ourselves. */
-      if (!! (ev.xkey.state & ShiftMask) != is.shift)
-         is.shift = !! (ev.xkey.state & ShiftMask);
-      if (!! (ev.xkey.state & ControlMask) != is.ctrl)
-         is.ctrl = !! (ev.xkey.state & ControlMask);
-      if (!! (ev.xkey.state & Mod1Mask) != is.alt)
-         is.alt = !! (ev.xkey.state & Mod1Mask);
-
-      /* It's a modifier ? Remember its state */
-      switch (ks)
-	 {
-	 case XK_Shift_L:
-	 case XK_Shift_R:
-	    is.shift = press;
-	    break;
-	 case XK_Control_L:
-	 case XK_Control_R:
-	    is.ctrl = press;
-	    break;
-	 case XK_Alt_L:
-	 case XK_Alt_R:
-	 case XK_Meta_L:
-	 case XK_Meta_R:
-	    is.alt = press;
+	/* Mouse buttons */
+    case ButtonPress:
+    case ButtonRelease:
+	{
+	    is.time = ev.xbutton.time;
+	    int press = (ev.type == ButtonPress);
+	    if (ev.xbutton.button == Button1)
+	    {
+		is.key = press ? YE_BUTL_PRESS : YE_BUTL_RELEASE;
+		is.butl = press;
+	    }
+	    else if (ev.xbutton.button == Button2)
+	    {
+		is.key = press ? YE_BUTM_PRESS : YE_BUTM_RELEASE;
+		is.butm = press;
+	    }
+	    else if (ev.xbutton.button == Button3)
+	    {
+		is.key = press ? YE_BUTR_PRESS : YE_BUTR_RELEASE;
+		is.butr = press;
+	    }
+	    else if (ev.xbutton.button == Button4)
+	    {
+		is.key = press ? YE_WHEEL_UP : 0;
+	    }
+	    else if (ev.xbutton.button == Button5)
+	    {
+		is.key = press ? YE_WHEEL_DOWN : 0;
+	    }
 	    break;
-	 }
+	}
+
+	/*
+	 * Keyboard
+	 * FIXME: need to handle NotifyKeymap event as well.
+	 */
+    case KeyPress:
+    case KeyRelease:
+	{
+	    KeySym ks;
+	    int press;
+	    unsigned char c;
+	    int has_string;
+
+	    is.time = ev.xkey.time;
+
+	    press = (ev.type == KeyPress);
+
+	    /* Convert keycode -> keysym + char. The keysym is useful for keys
+	       such as cursor arrows that don't have an ASCII code. */
+	    has_string =
+		XLookupString((XKeyEvent *) & ev, (char *) &c, 1, &ks, NULL);
+
+	    /* The event says that Ctrl, Alt and Shift are not in the state we
+	       thought they were. Don't panic ; it's just that we missed the
+	       modifier key press/release event as it happened when we didn't
+	       have focus. Adjust ourselves. */
+	    if (! !(ev.xkey.state & ShiftMask) != is.shift)
+		is.shift = ! !(ev.xkey.state & ShiftMask);
+	    if (! !(ev.xkey.state & ControlMask) != is.ctrl)
+		is.ctrl = ! !(ev.xkey.state & ControlMask);
+	    if (! !(ev.xkey.state & Mod1Mask) != is.alt)
+		is.alt = ! !(ev.xkey.state & Mod1Mask);
 
-      /* Process ordinary keys */
-      if (press)
-	 {
-	 size_t n;
-	 if (has_string)
-	    is.key = c;
-	 for (n = 0; n < sizeof key_info / sizeof *key_info; n++)
-	    if (key_info[n].ks == ks)
-	       {
-	       is.key = key_info[n].key;
-	       break;
-	       }
-	 if (is.key >= YK_ && is.key != YK_BACKTAB && is.shift)
-	    is.key |= YK_SHIFT;
-	 if (is.key >= YK_ && is.ctrl)
-	    is.key |= YK_CTRL;
-	 if (is.key != 0 && is.alt)
-	    is.key |= YK_ALT;
-	 }
+	    /* It's a modifier ? Remember its state */
+	    switch (ks)
+	    {
+	    case XK_Shift_L:
+	    case XK_Shift_R:
+		is.shift = press;
+		break;
+	    case XK_Control_L:
+	    case XK_Control_R:
+		is.ctrl = press;
+		break;
+	    case XK_Alt_L:
+	    case XK_Alt_R:
+	    case XK_Meta_L:
+	    case XK_Meta_R:
+		is.alt = press;
+		break;
+	    }
+
+	    /* Process ordinary keys */
+	    if (press)
+	    {
+		size_t n;
+		if (has_string)
+		    is.key = c;
+		for (n = 0; n < sizeof key_info / sizeof *key_info; n++)
+		    if (key_info[n].ks == ks)
+		    {
+			is.key = key_info[n].key;
+			break;
+		    }
+		if (is.key >= YK_ && is.key != YK_BACKTAB && is.shift)
+		    is.key |= YK_SHIFT;
+		if (is.key >= YK_ && is.ctrl)
+		    is.key |= YK_CTRL;
+		if (is.key != 0 && is.alt)
+		    is.key |= YK_ALT;
+	    }
 #if 0
-      if (ev.type == KeyPress)
-	 {
-	 printf ("key=%04hXh", is.key);
-	 if (is.key >= 0 && is.key <= UCHAR_MAX && isprint (is.key))
-	    printf (" (%c)", (char) is.key);
-	 putchar ('\n');
-	 }
+	    if (ev.type == KeyPress)
+	    {
+		printf("key=%04hXh", is.key);
+		if (is.key >= 0 && is.key <= UCHAR_MAX && isprint(is.key))
+		    printf(" (%c)", (char) is.key);
+		putchar('\n');
+	    }
 #endif
-      break;
-      }
-   }  /* switch (ev.type) */
+	    break;
+	}
+    }				/* switch (ev.type) */
 }
 
-#endif  /* #ifdef Y_X11 */
+#endif /* #ifdef Y_X11 */
 
 
 /*
  *	has_input_event
  *	Tells whether there are events in the input queue
  */
-int has_input_event ()
+int has_input_event()
 {
-XEvent xev;
-if (XCheckMaskEvent (dpy, 0xffffffff, &xev) == True)
-   {
-   XPutBackEvent (dpy, &xev);
-   return 1;
-   }
-return 0;
+    XEvent xev;
+    if (XCheckMaskEvent(dpy, 0xffffffff, &xev) == True)
+    {
+	XPutBackEvent(dpy, &xev);
+	return 1;
+    }
+    return 0;
 }
 
 
@@ -391,9 +393,9 @@
  *	Return 0 if there is no key press in the input queue, <>0 else.
  *	This is a convenience function to replace bioskey(1).
  */
-int have_key ()
+int have_key()
 {
-return 1;  /* FIXME!! */
+    return 1;			/* FIXME!! */
 }
 
 
@@ -402,12 +404,12 @@
  *	Wait until the user presses a key and returns its code.
  *	This is a convenience function to replace bioskey(0).
  */
-int get_key ()
+int get_key()
 {
-do
-   get_input_status ();
-while (! event_is_key (is.key));
-return is.key;
+    do
+	get_input_status();
+    while (!event_is_key(is.key));
+    return is.key;
 }
 
 
@@ -416,13 +418,13 @@
  *	Wait until the user presses a key or clicks the left button.
  *	In most cases, you should use this and not get_key().
  */
-void get_key_or_click ()
+void get_key_or_click()
 {
-do
-   get_input_status ();
-while (! event_is_key (is.key) && is.key != YE_BUTL_PRESS);
+    do
+	get_input_status();
+    while (!event_is_key(is.key) && is.key != YE_BUTL_PRESS);
 
-is.key = 0;  // FIXME Shouldn't have to do that but EditorLoop() is broken
+    is.key = 0;			// FIXME Shouldn't have to do that but EditorLoop() is broken
 }
 
 
@@ -435,85 +437,83 @@
  *	The string returned is guaranteed to have a length <= 50.
  */
 typedef struct
-   {
-   inpev_t key;
-   const char *string;
-   } key_string_t;
-static const key_string_t key_string[] =
-   {
-   { ' ',               "Space"         },
-   { YK_BACKSPACE, 	"BS"		},
-   { YK_BACKTAB,	"Shift-Tab"	},
-   { YK_DEL,       	"Del"		},
-   { YK_DOWN,      	"Down"		},
-   { YK_END,		"End"		},
-   { YK_ESC,		"Esc"		},
-   { YK_F1,		"F1"		},
-   { YK_F2,		"F2"		},
-   { YK_F3,		"F3"		},
-   { YK_F4,		"F4"		},
-   { YK_F5,		"F5"		},
-   { YK_F6,		"F6"		},
-   { YK_F7,		"F7"		},
-   { YK_F8,		"F8"		},
-   { YK_F9,		"F9"		},
-   { YK_F10,		"F10"		},
-   { YK_HOME,		"Home"		},
-   { YK_INS,		"Ins"		},
-   { YK_LEFT,		"Left"		},
-   { YK_PD,		"Pgdn"		},
-   { YK_PU,		"Pgup"		},
-   { YK_RETURN,		"Return"	},
-   { YK_RIGHT,		"Right"		},
-   { YK_TAB,		"Tab"		},
-   { YK_UP,		"Up"		},
-   };
+{
+    inpev_t key;
+    const char *string;
+} key_string_t;
+static const key_string_t key_string[] = {
+    {' ', "Space"},
+    {YK_BACKSPACE, "BS"},
+    {YK_BACKTAB, "Shift-Tab"},
+    {YK_DEL, "Del"},
+    {YK_DOWN, "Down"},
+    {YK_END, "End"},
+    {YK_ESC, "Esc"},
+    {YK_F1, "F1"},
+    {YK_F2, "F2"},
+    {YK_F3, "F3"},
+    {YK_F4, "F4"},
+    {YK_F5, "F5"},
+    {YK_F6, "F6"},
+    {YK_F7, "F7"},
+    {YK_F8, "F8"},
+    {YK_F9, "F9"},
+    {YK_F10, "F10"},
+    {YK_HOME, "Home"},
+    {YK_INS, "Ins"},
+    {YK_LEFT, "Left"},
+    {YK_PD, "Pgdn"},
+    {YK_PU, "Pgup"},
+    {YK_RETURN, "Return"},
+    {YK_RIGHT, "Right"},
+    {YK_TAB, "Tab"},
+    {YK_UP, "Up"},
+};
 
-const char *key_to_string (inpev_t k)
+const char *key_to_string(inpev_t k)
 {
-static char buf[51];
+    static char buf[51];
 
 // Is one of the special keys ?
-size_t n;
-const size_t nmax = sizeof key_string / sizeof *key_string;
-for (n = 0; n < nmax; n++)
-   if (key_string[n].key == k)
-      break;
+    size_t n;
+    const size_t nmax = sizeof key_string / sizeof *key_string;
+    for (n = 0; n < nmax; n++)
+	if (key_string[n].key == k)
+	    break;
 
-*buf = '\0';
-if (k & YK_CTRL || (n == nmax && k <= 31))
-   {
-   al_saps (buf, "Ctrl-", sizeof buf - 1);
-   if (k & YK_CTRL)
-      k ^= YK_CTRL;
-   if (k <= 31)
-      k += 96;  // Heavy ASCII-ism : 01h (^A) -> 61h ("a")
-   }
-if (k & YK_ALT)
-   {
-   al_saps (buf, "Alt-", sizeof buf - 1);
-   k ^= YK_ALT;
-   }
-if (k & YK_SHIFT)
-   {
-   al_saps (buf, "Shift-", sizeof buf - 1);
-   k ^= YK_SHIFT;
-   }
+    *buf = '\0';
+    if (k & YK_CTRL || (n == nmax && k <= 31))
+    {
+	al_saps(buf, "Ctrl-", sizeof buf - 1);
+	if (k & YK_CTRL)
+	    k ^= YK_CTRL;
+	if (k <= 31)
+	    k += 96;		// Heavy ASCII-ism : 01h (^A) -> 61h ("a")
+    }
+    if (k & YK_ALT)
+    {
+	al_saps(buf, "Alt-", sizeof buf - 1);
+	k ^= YK_ALT;
+    }
+    if (k & YK_SHIFT)
+    {
+	al_saps(buf, "Shift-", sizeof buf - 1);
+	k ^= YK_SHIFT;
+    }
 
-if (n == nmax)
-   if (k <= UCHAR_MAX && isprint (k))
-      al_sapc (buf, k, sizeof buf - 1);
-   else
-      {
-      al_sapc (buf, al_adigits[(k >> 12) & 15], sizeof buf - 1);
-      al_sapc (buf, al_adigits[(k >>  8) & 15], sizeof buf - 1);
-      al_sapc (buf, al_adigits[(k >>  4) & 15], sizeof buf - 1);
-      al_sapc (buf, al_adigits[(k >>  0) & 15], sizeof buf - 1);
-      }
-else
-   al_saps (buf, key_string[n].string, sizeof buf - 1);
+    if (n == nmax)
+	if (k <= UCHAR_MAX && isprint(k))
+	    al_sapc(buf, k, sizeof buf - 1);
+	else
+	{
+	    al_sapc(buf, al_adigits[(k >> 12) & 15], sizeof buf - 1);
+	    al_sapc(buf, al_adigits[(k >> 8) & 15], sizeof buf - 1);
+	    al_sapc(buf, al_adigits[(k >> 4) & 15], sizeof buf - 1);
+	    al_sapc(buf, al_adigits[(k >> 0) & 15], sizeof buf - 1);
+	}
+    else
+	al_saps(buf, key_string[n].string, sizeof buf - 1);
 
-buf[sizeof buf - 1] = '\0';  /* Paranoia */
-return buf;
+    buf[sizeof buf - 1] = '\0';	/* Paranoia */
+    return buf;
 }
-
--- a/src/input.h	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/input.h	Sat Sep 24 14:16:04 2011 +0300
@@ -30,26 +30,26 @@
 
 typedef unsigned short inpev_t;
 typedef struct
-  {
-  // Window events
-  int  width;		// New window width
-  int  height;		// New window height
-  // Mouse events
-  char in_window;	// <>0 iff mouse pointer is in window
-  char butl;		// <>0 iff left mouse button is depressed
-  char butm;		// <>0 iff middle mouse button is depressed
-  char butr;		// <>0 iff right mouse button is depressed
-  int x;		// Mouse pointer position
-  int y;
-  // Keyboard
-  char shift;		// <>0 iff either [Shift] is pressed
-  char ctrl;		// <>0 iff either [Ctrl] is pressed
-  char alt;		// <>0 iff either [Alt]/[Meta] is pressed
-  char scroll_lock;	// Always 0 for the moment
-  // General
-  inpev_t key;		// Code of last event (key, mouse, resize, expose...)
-  unsigned long time;	// Date of event in ms (1)
-  } input_status_t;
+{
+    // Window events
+    int width;			// New window width
+    int height;			// New window height
+    // Mouse events
+    char in_window;		// <>0 iff mouse pointer is in window
+    char butl;			// <>0 iff left mouse button is depressed
+    char butm;			// <>0 iff middle mouse button is depressed
+    char butr;			// <>0 iff right mouse button is depressed
+    int x;			// Mouse pointer position
+    int y;
+    // Keyboard
+    char shift;			// <>0 iff either [Shift] is pressed
+    char ctrl;			// <>0 iff either [Ctrl] is pressed
+    char alt;			// <>0 iff either [Alt]/[Meta] is pressed
+    char scroll_lock;		// Always 0 for the moment
+    // General
+    inpev_t key;		// Code of last event (key, mouse, resize, expose...)
+    unsigned long time;		// Date of event in ms (1)
+} input_status_t;
 
 /* Notes:
 (1) Defined only for the following events: key, button, motion
@@ -57,59 +57,59 @@
 */
 
 /* Events and key codes */
-const inpev_t YK_BACKSPACE	= '\b';
-const inpev_t YK_TAB		= '\t';
-const inpev_t YK_RETURN		= '\r';
-const inpev_t YK_ESC		= 0x1b;
-const inpev_t YK_DEL		= 0x7f;
-const inpev_t YK_		= 256;
-const inpev_t YK_BACKTAB	= 257;
-const inpev_t YK_DOWN		= 258;
-const inpev_t YK_END		= 259;
-const inpev_t YK_F1		= 260;
-const inpev_t YK_F2		= 261;
-const inpev_t YK_F3		= 262;
-const inpev_t YK_F4		= 263;
-const inpev_t YK_F5		= 264;
-const inpev_t YK_F6		= 265;
-const inpev_t YK_F7		= 266;
-const inpev_t YK_F8		= 267;
-const inpev_t YK_F9		= 268;
-const inpev_t YK_F10		= 269;
-const inpev_t YK_HOME		= 270;
-const inpev_t YK_INS		= 271;
-const inpev_t YK_LEFT		= 272;
-const inpev_t YK_PU		= 273;
-const inpev_t YK_PD		= 274;
-const inpev_t YK_RIGHT		= 275;
-const inpev_t YK_UP		= 276;
-const inpev_t YK__LAST		= 277;  // Marks the end of key events
+const inpev_t YK_BACKSPACE = '\b';
+const inpev_t YK_TAB = '\t';
+const inpev_t YK_RETURN = '\r';
+const inpev_t YK_ESC = 0x1b;
+const inpev_t YK_DEL = 0x7f;
+const inpev_t YK_ = 256;
+const inpev_t YK_BACKTAB = 257;
+const inpev_t YK_DOWN = 258;
+const inpev_t YK_END = 259;
+const inpev_t YK_F1 = 260;
+const inpev_t YK_F2 = 261;
+const inpev_t YK_F3 = 262;
+const inpev_t YK_F4 = 263;
+const inpev_t YK_F5 = 264;
+const inpev_t YK_F6 = 265;
+const inpev_t YK_F7 = 266;
+const inpev_t YK_F8 = 267;
+const inpev_t YK_F9 = 268;
+const inpev_t YK_F10 = 269;
+const inpev_t YK_HOME = 270;
+const inpev_t YK_INS = 271;
+const inpev_t YK_LEFT = 272;
+const inpev_t YK_PU = 273;
+const inpev_t YK_PD = 274;
+const inpev_t YK_RIGHT = 275;
+const inpev_t YK_UP = 276;
+const inpev_t YK__LAST = 277;	// Marks the end of key events
 
 // Those are not key numbers but window events
-const inpev_t YE_RESIZE		= 278;
-const inpev_t YE_EXPOSE		= 279;
+const inpev_t YE_RESIZE = 278;
+const inpev_t YE_EXPOSE = 279;
 
 // Those are not key numbers but mouse events
-const inpev_t YE_BUTL_PRESS	= 280;
-const inpev_t YE_BUTL_RELEASE	= 281;
-const inpev_t YE_BUTM_PRESS	= 282;
-const inpev_t YE_BUTM_RELEASE	= 283;
-const inpev_t YE_BUTR_PRESS	= 284;
-const inpev_t YE_BUTR_RELEASE	= 285;
-const inpev_t YE_WHEEL_UP	= 286;	// Negative, normally bound to button 4
-const inpev_t YE_WHEEL_DOWN	= 287;	// Positive, normally bound to button 5
-const inpev_t YE_ENTER		= 288;
-const inpev_t YE_LEAVE		= 289;
-const inpev_t YE_MOTION		= 290;
+const inpev_t YE_BUTL_PRESS = 280;
+const inpev_t YE_BUTL_RELEASE = 281;
+const inpev_t YE_BUTM_PRESS = 282;
+const inpev_t YE_BUTM_RELEASE = 283;
+const inpev_t YE_BUTR_PRESS = 284;
+const inpev_t YE_BUTR_RELEASE = 285;
+const inpev_t YE_WHEEL_UP = 286;	// Negative, normally bound to button 4
+const inpev_t YE_WHEEL_DOWN = 287;	// Positive, normally bound to button 5
+const inpev_t YE_ENTER = 288;
+const inpev_t YE_LEAVE = 289;
+const inpev_t YE_MOTION = 290;
 
 // Those are not key numbers but application events
 // (i.e. generated internally)
-const inpev_t YE_ZOOM_CHANGED	= 291;
+const inpev_t YE_ZOOM_CHANGED = 291;
 
 // Those are ORed with the other key numbers :
-const inpev_t YK_SHIFT		= 0x2000;
-const inpev_t YK_CTRL		= 0X4000; 
-const inpev_t YK_ALT		= 0x8000;
+const inpev_t YK_SHIFT = 0x2000;
+const inpev_t YK_CTRL = 0X4000;
+const inpev_t YK_ALT = 0x8000;
 
 /* Defined in input.c -- see the comment there */
 extern input_status_t is;
@@ -122,12 +122,10 @@
 /* Apply this to is.key to find out whether it contains a key press event. */
 #define event_is_key(n) (((n) & (YK_SHIFT-1)) > 0 && ((n) & (YK_SHIFT-1)) < YK__LAST)
 
-void init_input_status ();
-void get_input_status ();
-int  has_input_event ();
-int  have_key ();
-int  get_key ();
-void get_key_or_click ();
-const char *key_to_string (inpev_t k);
-
-
+void init_input_status();
+void get_input_status();
+int has_input_event();
+int have_key();
+int get_key();
+void get_key_or_click();
+const char *key_to_string(inpev_t k);
--- a/src/l_align.cc	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/l_align.cc	Sat Sep 24 14:16:04 2011 +0300
@@ -43,44 +43,44 @@
    get the absolute height from which the textures are drawn
 */
 
-int GetTextureRefHeight (int sidedef) /* SWAP! */
+int GetTextureRefHeight(int sidedef)	/* SWAP! */
 {
-int l, sector;
-int otherside = OBJ_NO_NONE;
+    int l, sector;
+    int otherside = OBJ_NO_NONE;
 
 /* find the sidedef on the other side of the LineDef, if any */
-for (l = 0; l < NumLineDefs; l++)
-  {
-  if (LineDefs[l].sidedef1 == sidedef)
+    for (l = 0; l < NumLineDefs; l++)
     {
-    otherside = LineDefs[l].sidedef2;
-    break;
+	if (LineDefs[l].sidedef1 == sidedef)
+	{
+	    otherside = LineDefs[l].sidedef2;
+	    break;
+	}
+	if (LineDefs[l].sidedef2 == sidedef)
+	{
+	    otherside = LineDefs[l].sidedef1;
+	    break;
+	}
     }
-  if (LineDefs[l].sidedef2 == sidedef)
-    {
-    otherside = LineDefs[l].sidedef1;
-    break;
-    }
-  }
 /* get the Sector number */
-sector = SideDefs[sidedef].sector;
+    sector = SideDefs[sidedef].sector;
 /* if the upper texture is displayed,
    then the reference is taken from the other Sector */
-if (otherside >= 0)
-  {
-  l = SideDefs[otherside].sector;
-  if (l > 0)
+    if (otherside >= 0)
     {
-    if (Sectors[l].ceilh < Sectors[sector].ceilh
-     && Sectors[l].ceilh > Sectors[sector].floorh)
-      sector = l;
+	l = SideDefs[otherside].sector;
+	if (l > 0)
+	{
+	    if (Sectors[l].ceilh < Sectors[sector].ceilh
+		&& Sectors[l].ceilh > Sectors[sector].floorh)
+		sector = l;
+	}
     }
-  }
 /* return the altitude of the ceiling */
-if (sector >= 0)
-  return Sectors[sector].ceilh; /* textures are drawn from the ceiling down */
-else
-  return 0; /* yuck! */
+    if (sector >= 0)
+	return Sectors[sector].ceilh;	/* textures are drawn from the ceiling down */
+    else
+	return 0;		/* yuck! */
 }
 
 
@@ -97,26 +97,26 @@
       way to select only one side of a two-sided wall.
 */
 
-void AlignTexturesY (SelPtr *sdlist) /* SWAP! */
+void AlignTexturesY(SelPtr * sdlist)	/* SWAP! */
 {
-int h, refh;
+    int h, refh;
 
-if (! *sdlist)
-   return;
+    if (!*sdlist)
+	return;
 
 /* get the reference height from the first sidedef */
-refh = GetTextureRefHeight ((*sdlist)->objnum);
-SideDefs[(*sdlist)->objnum].yoff = 0;
-UnSelectObject (sdlist, (*sdlist)->objnum);
+    refh = GetTextureRefHeight((*sdlist)->objnum);
+    SideDefs[(*sdlist)->objnum].yoff = 0;
+    UnSelectObject(sdlist, (*sdlist)->objnum);
 
 /* adjust Y offset in all other SideDefs */
-while (*sdlist)
-  {
-  h = GetTextureRefHeight ((*sdlist)->objnum);
-  SideDefs[(*sdlist)->objnum].yoff = (refh - h) % 128;
-  UnSelectObject (sdlist, (*sdlist)->objnum);
-  }
-MadeChanges = 1;
+    while (*sdlist)
+    {
+	h = GetTextureRefHeight((*sdlist)->objnum);
+	SideDefs[(*sdlist)->objnum].yoff = (refh - h) % 128;
+	UnSelectObject(sdlist, (*sdlist)->objnum);
+    }
+    MadeChanges = 1;
 }
 
 
@@ -140,256 +140,282 @@
    the following needs to be altered radically.
 */
 
-void AlignTexturesX (SelPtr *sdlist) /* SWAP! */
+void AlignTexturesX(SelPtr * sdlist)	/* SWAP! */
 {
-			/* FIRST texture name used in the highlited objects */
-char texname[WAD_TEX_NAME + 1];
-char errormessage[80];	/* area to hold the error messages produced */
-int  ldef;		/* linedef number */
-int  sd1;		/* current sidedef in *sdlist */
-int  vert1, vert2;	/* vertex 1 and 2 for the linedef under scrutiny */
-int  xoffset;		/* xoffset accumulator */
-int  useroffset;	/* user input offset for first input */
-i16  texlength;		/* the length of texture to format to */
-int  length;		/* length of linedef under scrutiny */
-i16  dummy;		/* holds useless data */
-int  type_off;		/* do we have an initial offset to use */
-int  type_tex;		/* do we check for same textures */
-int  type_sd;		/* do we align sidedef 1 or sidedef 2 */
+    /* FIRST texture name used in the highlited objects */
+    char texname[WAD_TEX_NAME + 1];
+    char errormessage[80];	/* area to hold the error messages produced */
+    int ldef;			/* linedef number */
+    int sd1;			/* current sidedef in *sdlist */
+    int vert1, vert2;		/* vertex 1 and 2 for the linedef under scrutiny */
+    int xoffset;		/* xoffset accumulator */
+    int useroffset;		/* user input offset for first input */
+    i16 texlength;		/* the length of texture to format to */
+    int length;			/* length of linedef under scrutiny */
+    i16 dummy;			/* holds useless data */
+    int type_off;		/* do we have an initial offset to use */
+    int type_tex;		/* do we check for same textures */
+    int type_sd;		/* do we align sidedef 1 or sidedef 2 */
 
-type_sd  = 0;		/* which sidedef to align, 1=SideDef1, 2=SideDef2 */
-type_tex = 0;		/* do we test for similar textures, 0 = no, 1 = yes */
-type_off = 0;		/* do we have an inital offset, 0 = no, 1 = yes */
+    type_sd = 0;		/* which sidedef to align, 1=SideDef1, 2=SideDef2 */
+    type_tex = 0;		/* do we test for similar textures, 0 = no, 1 = yes */
+    type_off = 0;		/* do we have an inital offset, 0 = no, 1 = yes */
 
-vert1   = -1;
-vert2   = -1;		/* 1st time round the while loop the -1 value is needed */
-texlength  = 0;
-xoffset    = 0;
-useroffset = 0;
+    vert1 = -1;
+    vert2 = -1;			/* 1st time round the while loop the -1 value is needed */
+    texlength = 0;
+    xoffset = 0;
+    useroffset = 0;
 
-switch (vDisplayMenu (250, 110, "Aligning textures (X offset) :",
-
-	" Sidedef 1, Check for identical textures.     ", YK_, 0,
-	" Sidedef 1, As above, but with inital offset. ", YK_, 0,
-	" Sidedef 1, No texture checking.              ", YK_, 0,
-	" Sidedef 1, As above, but with inital offset. ", YK_, 0,
+    switch (vDisplayMenu(250, 110, "Aligning textures (X offset) :",
+			 " Sidedef 1, Check for identical textures.     ",
+			 YK_, 0,
+			 " Sidedef 1, As above, but with inital offset. ",
+			 YK_, 0,
+			 " Sidedef 1, No texture checking.              ",
+			 YK_, 0,
+			 " Sidedef 1, As above, but with inital offset. ",
+			 YK_, 0,
+			 " Sidedef 2, Check for identical textures.     ",
+			 YK_, 0,
+			 " Sidedef 2, As above, but with inital offset. ",
+			 YK_, 0,
+			 " Sidedef 2, No texture checking.              ",
+			 YK_, 0,
+			 " Sidedef 2, As above, but with inital offset. ",
+			 YK_, 0, NULL))
+    {
+    case 1:			/* Sidedef 1 with checking for same textures   */
+	type_sd = 1;
+	type_tex = 1;
+	type_off = 0;
+	break;
 
-	" Sidedef 2, Check for identical textures.     ", YK_, 0,
-	" Sidedef 2, As above, but with inital offset. ", YK_, 0,
-	" Sidedef 2, No texture checking.              ", YK_, 0,
-	" Sidedef 2, As above, but with inital offset. ", YK_, 0,
-	NULL))
-  {
-  case 1:       /* Sidedef 1 with checking for same textures   */
-    type_sd = 1; type_tex = 1; type_off = 0;
-    break;
+    case 2:			/* Sidedef 1 as above, but with inital offset  */
+	type_sd = 1;
+	type_tex = 1;
+	type_off = 1;
+	break;
 
-  case 2:       /* Sidedef 1 as above, but with inital offset  */
-    type_sd = 1; type_tex = 1; type_off = 1;
-    break;
-
-  case 3:       /* Sidedef 1 regardless of same textures       */
-    type_sd = 1; type_tex = 0; type_off = 0;
-    break;
-
-  case 4:       /* Sidedef 1 as above, but with inital offset  */
-    type_sd = 1; type_tex = 0; type_off = 1;
-    break;
+    case 3:			/* Sidedef 1 regardless of same textures       */
+	type_sd = 1;
+	type_tex = 0;
+	type_off = 0;
+	break;
 
-  case 5:       /* Sidedef 2 with checking for same textures   */
-    type_sd = 2; type_tex = 1; type_off = 0;
-    break;
+    case 4:			/* Sidedef 1 as above, but with inital offset  */
+	type_sd = 1;
+	type_tex = 0;
+	type_off = 1;
+	break;
 
-  case 6:       /* Sidedef 2 as above, but with initial offset */
-    type_sd = 2; type_tex = 1; type_off = 1;
-    break;
-
-  case 7:       /* Sidedef 2 regardless of same textures       */
-    type_sd = 2; type_tex = 0; type_off = 0;
-    break;
+    case 5:			/* Sidedef 2 with checking for same textures   */
+	type_sd = 2;
+	type_tex = 1;
+	type_off = 0;
+	break;
 
-  case 8:       /* Sidedef 2 as above, but with initial offset */
-    type_sd = 2; type_tex = 0; type_off = 1;
-    break;
-  }
+    case 6:			/* Sidedef 2 as above, but with initial offset */
+	type_sd = 2;
+	type_tex = 1;
+	type_off = 1;
+	break;
 
-ldef = 0;
-if (! *sdlist)
-   {
-   Notify (-1, -1, "Error in AlignTexturesX: list is empty", 0);
-   return;
-   }
-sd1 = (*sdlist)->objnum;
+    case 7:			/* Sidedef 2 regardless of same textures       */
+	type_sd = 2;
+	type_tex = 0;
+	type_off = 0;
+	break;
+
+    case 8:			/* Sidedef 2 as above, but with initial offset */
+	type_sd = 2;
+	type_tex = 0;
+	type_off = 1;
+	break;
+    }
 
-if (type_sd == 1) /* throw out all 2nd SideDefs untill a 1st is found */
-  {
-  while (*sdlist && LineDefs[ldef].sidedef1!=sd1 && ldef<=NumLineDefs)
+    ldef = 0;
+    if (!*sdlist)
     {
-    ldef++;
-    if (LineDefs[ldef].sidedef2 == sd1)
-      {
-      UnSelectObject (sdlist, (*sdlist)->objnum);
-      if (! *sdlist)
-         return;
-      sd1 = (*sdlist)->objnum;
-      ldef = 0;
-      }
+	Notify(-1, -1, "Error in AlignTexturesX: list is empty", 0);
+	return;
     }
-  }
+    sd1 = (*sdlist)->objnum;
 
-if (type_sd == 2) /* throw out all 1st SideDefs untill a 2nd is found */
-  {
-  while (LineDefs[ldef].sidedef2!=sd1 && ldef<=NumLineDefs)
+    if (type_sd == 1)		/* throw out all 2nd SideDefs untill a 1st is found */
     {
-    ldef++;
-    if (LineDefs[ldef].sidedef1 == sd1)
-      {
-      UnSelectObject (sdlist, (*sdlist)->objnum);
-      if (! *sdlist)
-	 return;
-      sd1 = (*sdlist)->objnum;
-      ldef = 0;
-      }
+	while (*sdlist && LineDefs[ldef].sidedef1 != sd1
+	       && ldef <= NumLineDefs)
+	{
+	    ldef++;
+	    if (LineDefs[ldef].sidedef2 == sd1)
+	    {
+		UnSelectObject(sdlist, (*sdlist)->objnum);
+		if (!*sdlist)
+		    return;
+		sd1 = (*sdlist)->objnum;
+		ldef = 0;
+	    }
+	}
     }
-  }
+
+    if (type_sd == 2)		/* throw out all 1st SideDefs untill a 2nd is found */
+    {
+	while (LineDefs[ldef].sidedef2 != sd1 && ldef <= NumLineDefs)
+	{
+	    ldef++;
+	    if (LineDefs[ldef].sidedef1 == sd1)
+	    {
+		UnSelectObject(sdlist, (*sdlist)->objnum);
+		if (!*sdlist)
+		    return;
+		sd1 = (*sdlist)->objnum;
+		ldef = 0;
+	    }
+	}
+    }
 
 /* get texture name of the sidedef in the *sdlist) */
-strncpy (texname, SideDefs[(*sdlist)->objnum].tex3, WAD_TEX_NAME);
+    strncpy(texname, SideDefs[(*sdlist)->objnum].tex3, WAD_TEX_NAME);
 
 /* test if there is a texture there */
-if (texname[0] == '-')
-  {
-  Beep ();
-  sprintf (errormessage, "No texture for sidedef #%d.", (*sdlist)->objnum);
-  Notify (-1, -1, errormessage, 0);
-  return;
-  }
+    if (texname[0] == '-')
+    {
+	Beep();
+	sprintf(errormessage, "No texture for sidedef #%d.",
+		(*sdlist)->objnum);
+	Notify(-1, -1, errormessage, 0);
+	return;
+    }
 
-GetWallTextureSize (&texlength, &dummy, texname); /* clunky, but it works */
+    GetWallTextureSize(&texlength, &dummy, texname);	/* clunky, but it works */
 
 /* get initial offset to use (if required) */
-if (type_off == 1)    /* source taken from InputObjectNumber */
-   {
-   int  x0;          /* left hand (x) window start     */
-   int  y0;          /* top (y) window start           */
-   int  key;         /* holds value returned by InputInteger */
-   char prompt[80];  /* prompt for inital offset input */
+    if (type_off == 1)		/* source taken from InputObjectNumber */
+    {
+	int x0;			/* left hand (x) window start     */
+	int y0;			/* top (y) window start           */
+	int key;		/* holds value returned by InputInteger */
+	char prompt[80];	/* prompt for inital offset input */
 
-   sprintf (prompt, "Enter initial offset between 0 and %d:", (int) texlength);
+	sprintf(prompt, "Enter initial offset between 0 and %d:",
+		(int) texlength);
 
-   x0 = (ScrMaxX - 25 - 8 * strlen (prompt)) / 2;
-   y0 = (ScrMaxY - 55) / 2;
+	x0 = (ScrMaxX - 25 - 8 * strlen(prompt)) / 2;
+	y0 = (ScrMaxY - 55) / 2;
 
-   DrawScreenBox3D (x0, y0, x0 + 25 + 8 * strlen (prompt), y0 + 55);
-   set_colour (WHITE);
-   DrawScreenText (x0 + 10, y0 + 8, prompt);
+	DrawScreenBox3D(x0, y0, x0 + 25 + 8 * strlen(prompt), y0 + 55);
+	set_colour(WHITE);
+	DrawScreenText(x0 + 10, y0 + 8, prompt);
 
-   while  ((key=InputInteger (x0+10, y0+28, &useroffset, 0, (int) texlength))
-	    != YK_RETURN && key != YK_ESC)
-      Beep ();
+	while ((key =
+		InputInteger(x0 + 10, y0 + 28, &useroffset, 0,
+			     (int) texlength)) != YK_RETURN && key != YK_ESC)
+	    Beep();
 
-   }
+    }
 
-while (*sdlist)  /* main processing loop */
-   {
-   ldef = 0;
-   sd1 = (*sdlist)->objnum;
+    while (*sdlist)		/* main processing loop */
+    {
+	ldef = 0;
+	sd1 = (*sdlist)->objnum;
 
-   if (type_sd == 1) /* throw out all 2nd SideDefs untill a 1st is found */
-   {
-     while (LineDefs[ldef].sidedef1!=sd1 && ldef<=NumLineDefs)
-       {
-       ldef++;
-       if (LineDefs[ldef].sidedef2 == sd1)
-	 {
-	 UnSelectObject (sdlist, (*sdlist)->objnum);
-	 sd1 = (*sdlist)->objnum;
-	 ldef = 0;
-	 if (! *sdlist)
-	    return;
-	 }
-       }
-     }
+	if (type_sd == 1)	/* throw out all 2nd SideDefs untill a 1st is found */
+	{
+	    while (LineDefs[ldef].sidedef1 != sd1 && ldef <= NumLineDefs)
+	    {
+		ldef++;
+		if (LineDefs[ldef].sidedef2 == sd1)
+		{
+		    UnSelectObject(sdlist, (*sdlist)->objnum);
+		    sd1 = (*sdlist)->objnum;
+		    ldef = 0;
+		    if (!*sdlist)
+			return;
+		}
+	    }
+	}
 
-   if (type_sd == 2) /* throw out all 1st SideDefs untill a 2nd is found */
-     {
-     while (LineDefs[ldef].sidedef2!=sd1 && ldef<=NumLineDefs)
-       {
-       ldef++;
-       if (LineDefs[ldef].sidedef1 == sd1)
-	 {
-	 UnSelectObject (sdlist, (*sdlist)->objnum);
-	 sd1 = (*sdlist)->objnum;
-	 ldef = 0;
-	 if (! *sdlist)
-	    return;
-	 }
-       }
-     }
+	if (type_sd == 2)	/* throw out all 1st SideDefs untill a 2nd is found */
+	{
+	    while (LineDefs[ldef].sidedef2 != sd1 && ldef <= NumLineDefs)
+	    {
+		ldef++;
+		if (LineDefs[ldef].sidedef1 == sd1)
+		{
+		    UnSelectObject(sdlist, (*sdlist)->objnum);
+		    sd1 = (*sdlist)->objnum;
+		    ldef = 0;
+		    if (!*sdlist)
+			return;
+		}
+	    }
+	}
 
-   /* do we test for same textures for the sidedef in question?? */
-   if (type_tex == 1)
-     {
-     if (strncmp (SideDefs[(*sdlist)->objnum].tex3, texname,WAD_TEX_NAME))
-       {
-       Beep ();
-       sprintf (errormessage, "No texture for sidedef #%d.", (*sdlist)->objnum);
-       Notify (-1, -1, errormessage, 0);
-       return;
-       }
-     }
+	/* do we test for same textures for the sidedef in question?? */
+	if (type_tex == 1)
+	{
+	    if (strncmp
+		(SideDefs[(*sdlist)->objnum].tex3, texname, WAD_TEX_NAME))
+	    {
+		Beep();
+		sprintf(errormessage, "No texture for sidedef #%d.",
+			(*sdlist)->objnum);
+		Notify(-1, -1, errormessage, 0);
+		return;
+	    }
+	}
 
-   sd1 = (*sdlist)->objnum;
-   ldef = 0;
+	sd1 = (*sdlist)->objnum;
+	ldef = 0;
 
-   /* find out which linedef holds that sidedef */
-   if (type_sd == 1)
-     {
-     while (LineDefs[ldef].sidedef1 != sd1 && ldef < NumLineDefs)
-	ldef++;
-     }
-   else
-     {
-     while (LineDefs[ldef].sidedef2 != sd1 && ldef < NumLineDefs)
-       ldef++;
-     }
+	/* find out which linedef holds that sidedef */
+	if (type_sd == 1)
+	{
+	    while (LineDefs[ldef].sidedef1 != sd1 && ldef < NumLineDefs)
+		ldef++;
+	}
+	else
+	{
+	    while (LineDefs[ldef].sidedef2 != sd1 && ldef < NumLineDefs)
+		ldef++;
+	}
 
-   vert1 = LineDefs[ldef].start;
-   /* test for linedef highlight continuity */
-   if (vert1 != vert2 && vert2 != -1)
-     {
-     Beep ();
-     sprintf (errormessage, "Linedef #%d is not contiguous"
-       " with the previous linedef, please reselect.", (*sdlist)->objnum);
-     Notify (-1, -1, errormessage, 0);
-     return;
-     }
-   /* is this the first time round here */
-   if (vert1 != vert2)
-     {
-     if (type_off == 1)  /* do we have an initial offset ? */
-       {
-       SideDefs[sd1].xoff = useroffset;
-       xoffset = useroffset;
-       }
-     else
-	SideDefs[sd1].xoff = 0;
-     }
-   else     /* put new xoffset into the sidedef */
-     SideDefs[sd1].xoff = xoffset;
+	vert1 = LineDefs[ldef].start;
+	/* test for linedef highlight continuity */
+	if (vert1 != vert2 && vert2 != -1)
+	{
+	    Beep();
+	    sprintf(errormessage, "Linedef #%d is not contiguous"
+		    " with the previous linedef, please reselect.",
+		    (*sdlist)->objnum);
+	    Notify(-1, -1, errormessage, 0);
+	    return;
+	}
+	/* is this the first time round here */
+	if (vert1 != vert2)
+	{
+	    if (type_off == 1)	/* do we have an initial offset ? */
+	    {
+		SideDefs[sd1].xoff = useroffset;
+		xoffset = useroffset;
+	    }
+	    else
+		SideDefs[sd1].xoff = 0;
+	}
+	else			/* put new xoffset into the sidedef */
+	    SideDefs[sd1].xoff = xoffset;
 
-   /* calculate length of linedef */
-   vert2 = LineDefs[ldef].end;
-   length = ComputeDist (Vertices[vert2].x - Vertices[vert1].x,
-			 Vertices[vert2].y - Vertices[vert1].y);
+	/* calculate length of linedef */
+	vert2 = LineDefs[ldef].end;
+	length = ComputeDist(Vertices[vert2].x - Vertices[vert1].x,
+			     Vertices[vert2].y - Vertices[vert1].y);
 
-   xoffset += length;
-   /* remove multiples of texlength from xoffset */
-   xoffset = xoffset % texlength;
-   /* move to next object in selected list */
-   UnSelectObject (sdlist, (*sdlist)->objnum);
-   }
-MadeChanges = 1;
+	xoffset += length;
+	/* remove multiples of texlength from xoffset */
+	xoffset = xoffset % texlength;
+	/* move to next object in selected list */
+	UnSelectObject(sdlist, (*sdlist)->objnum);
+    }
+    MadeChanges = 1;
 }
-
-
--- a/src/l_centre.cc	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/l_centre.cc	Sat Sep 24 14:16:04 2011 +0300
@@ -38,36 +38,34 @@
  *	centre_of_linedefs
  *	Return the coordinates of the centre of a group of linedefs.
  */
-void centre_of_linedefs (SelPtr list, int *x, int *y)
+void centre_of_linedefs(SelPtr list, int *x, int *y)
 {
-bitvec_c *vertices;
-int nitems;
-long x_sum;
-long y_sum;
-int n;
+    bitvec_c *vertices;
+    int nitems;
+    long x_sum;
+    long y_sum;
+    int n;
 
-vertices = bv_vertices_of_linedefs (list);
-x_sum = 0;
-y_sum = 0;
-nitems = 0;
-for (n = 0; n < NumVertices; n++)
-   if (vertices->get (n))
-      {
-      x_sum += Vertices[n].x;
-      y_sum += Vertices[n].y;
-      nitems++;
-      }
-if (nitems == 0)
-   {
-   *x = 0;
-   *y = 0;
-   }
-else
-   {
-   *x = (int) (x_sum / nitems);
-   *y = (int) (y_sum / nitems);
-   }
-delete vertices;
+    vertices = bv_vertices_of_linedefs(list);
+    x_sum = 0;
+    y_sum = 0;
+    nitems = 0;
+    for (n = 0; n < NumVertices; n++)
+	if (vertices->get(n))
+	{
+	    x_sum += Vertices[n].x;
+	    y_sum += Vertices[n].y;
+	    nitems++;
+	}
+    if (nitems == 0)
+    {
+	*x = 0;
+	*y = 0;
+    }
+    else
+    {
+	*x = (int) (x_sum / nitems);
+	*y = (int) (y_sum / nitems);
+    }
+    delete vertices;
 }
-
-
--- a/src/l_centre.h	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/l_centre.h	Sat Sep 24 14:16:04 2011 +0300
@@ -4,6 +4,4 @@
  */
 
 
-void centre_of_linedefs (SelPtr list, int *x, int *y);
-
-
+void centre_of_linedefs(SelPtr list, int *x, int *y);
--- a/src/l_flags.cc	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/l_flags.cc	Sat Sep 24 14:16:04 2011 +0300
@@ -38,31 +38,29 @@
  *	For all the linedefs in <list>, apply the operator <op>
  *	with the operand <operand> on the flags field.
  */
-void frob_linedefs_flags (SelPtr list, int op, int operand)
+void frob_linedefs_flags(SelPtr list, int op, int operand)
 {
-  SelPtr cur;
-  i16 mask;
+    SelPtr cur;
+    i16 mask;
 
-  if (op == YO_CLEAR || op == YO_SET || op == YO_TOGGLE)
-    mask = 1 << operand;
-  else
-    mask = operand;
+    if (op == YO_CLEAR || op == YO_SET || op == YO_TOGGLE)
+	mask = 1 << operand;
+    else
+	mask = operand;
 
-  for (cur = list; cur; cur = cur->next)
-  {
-    if (op == YO_CLEAR)
-      LineDefs[cur->objnum].flags &= ~mask;
-    else if (op == YO_SET)
-      LineDefs[cur->objnum].flags |= mask;
-    else if (op == YO_TOGGLE)
-      LineDefs[cur->objnum].flags ^= mask;
-    else
+    for (cur = list; cur; cur = cur->next)
     {
-      nf_bug ("frob_linedef_flags: op=%02X", op);
-      return;
+	if (op == YO_CLEAR)
+	    LineDefs[cur->objnum].flags &= ~mask;
+	else if (op == YO_SET)
+	    LineDefs[cur->objnum].flags |= mask;
+	else if (op == YO_TOGGLE)
+	    LineDefs[cur->objnum].flags ^= mask;
+	else
+	{
+	    nf_bug("frob_linedef_flags: op=%02X", op);
+	    return;
+	}
     }
-  }
-  MadeChanges = 1;
+    MadeChanges = 1;
 }
-
-
--- a/src/l_flags.h	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/l_flags.h	Sat Sep 24 14:16:04 2011 +0300
@@ -4,6 +4,4 @@
  */
 
 
-void frob_linedefs_flags (SelPtr list, int op, int operand);
-
-
+void frob_linedefs_flags(SelPtr list, int op, int operand);
--- a/src/l_misc.cc	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/l_misc.cc	Sat Sep 24 14:16:04 2011 +0300
@@ -36,34 +36,34 @@
 #include <math.h>
 
 
-static void SliceLinedef (int linedefno, int times);
+static void SliceLinedef(int linedefno, int times);
 
 
 /*
    flip one or several LineDefs
 */
 
-void FlipLineDefs ( SelPtr obj, bool swapvertices) /* SWAP! */
-{
-SelPtr cur;
-int    tmp;
-
-for (cur = obj; cur; cur = cur->next)
+void FlipLineDefs(SelPtr obj, bool swapvertices)	/* SWAP! */
 {
-   if (swapvertices)
-   {
-      /* swap starting and ending Vertices */
-      tmp = LineDefs[ cur->objnum].end;
-      LineDefs[ cur->objnum].end = LineDefs[ cur->objnum].start;
-      LineDefs[ cur->objnum].start = tmp;
-   }
-   /* swap first and second SideDefs */
-   tmp = LineDefs[ cur->objnum].sidedef1;
-   LineDefs[ cur->objnum].sidedef1 = LineDefs[ cur->objnum].sidedef2;
-   LineDefs[ cur->objnum].sidedef2 = tmp;
-}
-MadeChanges = 1;
-MadeMapChanges = 1;
+    SelPtr cur;
+    int tmp;
+
+    for (cur = obj; cur; cur = cur->next)
+    {
+	if (swapvertices)
+	{
+	    /* swap starting and ending Vertices */
+	    tmp = LineDefs[cur->objnum].end;
+	    LineDefs[cur->objnum].end = LineDefs[cur->objnum].start;
+	    LineDefs[cur->objnum].start = tmp;
+	}
+	/* swap first and second SideDefs */
+	tmp = LineDefs[cur->objnum].sidedef1;
+	LineDefs[cur->objnum].sidedef1 = LineDefs[cur->objnum].sidedef2;
+	LineDefs[cur->objnum].sidedef2 = tmp;
+    }
+    MadeChanges = 1;
+    MadeMapChanges = 1;
 }
 
 
@@ -71,21 +71,23 @@
    split one or more LineDefs in two, adding new Vertices in the middle
 */
 
-void SplitLineDefs ( SelPtr obj) /* SWAP! */
+void SplitLineDefs(SelPtr obj)	/* SWAP! */
 {
-SelPtr cur;
-int    vstart, vend;
+    SelPtr cur;
+    int vstart, vend;
 
-for (cur = obj; cur; cur = cur->next)
-  {
-  vstart = LineDefs[cur->objnum].start;
-  vend   = LineDefs[cur->objnum].end;
-  SliceLinedef (cur->objnum, 1);
-  Vertices[NumVertices-1].x = (Vertices[vstart].x + Vertices[vend].x) / 2;
-  Vertices[NumVertices-1].y = (Vertices[vstart].y + Vertices[vend].y) / 2;
-  }
-MadeChanges = 1;
-MadeMapChanges = 1;
+    for (cur = obj; cur; cur = cur->next)
+    {
+	vstart = LineDefs[cur->objnum].start;
+	vend = LineDefs[cur->objnum].end;
+	SliceLinedef(cur->objnum, 1);
+	Vertices[NumVertices - 1].x =
+	    (Vertices[vstart].x + Vertices[vend].x) / 2;
+	Vertices[NumVertices - 1].y =
+	    (Vertices[vstart].y + Vertices[vend].y) / 2;
+    }
+    MadeChanges = 1;
+    MadeMapChanges = 1;
 }
 
 
@@ -102,60 +104,64 @@
  *	This is true when convex is false. If convex is true, the nook
  *	is actually a bump when viewed from the 1st sidedef.
  */
-void MakeRectangularNook (SelPtr obj, int width, int depth, int convex) /* SWAP! */
+void MakeRectangularNook(SelPtr obj, int width, int depth, int convex)	/* SWAP! */
 {
-SelPtr cur;
+    SelPtr cur;
 
-for (cur = obj; cur; cur = cur->next)
-  {
-  int vstart, vend;
-  int x0;
-  int y0;
-  int dx0, dx1, dx2;
-  int dy0, dy1, dy2;
-  int line_len;
-  double real_width;
-  double angle;
+    for (cur = obj; cur; cur = cur->next)
+    {
+	int vstart, vend;
+	int x0;
+	int y0;
+	int dx0, dx1, dx2;
+	int dy0, dy1, dy2;
+	int line_len;
+	double real_width;
+	double angle;
 
-  vstart = LineDefs[cur->objnum].start;
-  vend   = LineDefs[cur->objnum].end;
-  x0     = Vertices[vstart].x;
-  y0     = Vertices[vstart].y;
-  dx0    = Vertices[vend].x - x0;
-  dy0    = Vertices[vend].y - y0;
+	vstart = LineDefs[cur->objnum].start;
+	vend = LineDefs[cur->objnum].end;
+	x0 = Vertices[vstart].x;
+	y0 = Vertices[vstart].y;
+	dx0 = Vertices[vend].x - x0;
+	dy0 = Vertices[vend].y - y0;
 
-  /* First split the line 4 times */
-  SliceLinedef (cur->objnum, 4);
+	/* First split the line 4 times */
+	SliceLinedef(cur->objnum, 4);
+
+	/* Then position the vertices */
+	angle = atan2(dy0, dx0);
 
-  /* Then position the vertices */
-  angle  = atan2 (dy0, dx0);
- 
-  /* If line to split is not longer than sidelen,
-     force sidelen to 1/3 of length */
-  line_len   = ComputeDist (dx0, dy0);
-  real_width = line_len > width ? width : line_len / 3;
-    
-  dx2 = (int) (real_width * cos (angle));
-  dy2 = (int) (real_width * sin (angle));
+	/* If line to split is not longer than sidelen,
+	   force sidelen to 1/3 of length */
+	line_len = ComputeDist(dx0, dy0);
+	real_width = line_len > width ? width : line_len / 3;
 
-  dx1 = (dx0 - dx2) / 2;
-  dy1 = (dy0 - dy2) / 2;
+	dx2 = (int) (real_width * cos(angle));
+	dy2 = (int) (real_width * sin(angle));
+
+	dx1 = (dx0 - dx2) / 2;
+	dy1 = (dy0 - dy2) / 2;
 
-  {
-  double normal = convex ? angle-HALFPI : angle+HALFPI;
-  Vertices[NumVertices-1-3].x = x0 + dx1;
-  Vertices[NumVertices-1-3].y = y0 + dy1;
-  Vertices[NumVertices-1-2].x = x0 + dx1 + (int) (depth * cos (normal));
-  Vertices[NumVertices-1-2].y = y0 + dy1 + (int) (depth * sin (normal));
-  Vertices[NumVertices-1-1].x = x0 + dx1 + dx2 + (int) (depth * cos (normal));
-  Vertices[NumVertices-1-1].y = y0 + dy1 + dy2 + (int) (depth * sin (normal));
-  Vertices[NumVertices-1  ].x = x0 + dx1 + dx2;
-  Vertices[NumVertices-1  ].y = y0 + dy1 + dy2;
-  }
+	{
+	    double normal = convex ? angle - HALFPI : angle + HALFPI;
+	    Vertices[NumVertices - 1 - 3].x = x0 + dx1;
+	    Vertices[NumVertices - 1 - 3].y = y0 + dy1;
+	    Vertices[NumVertices - 1 - 2].x =
+		x0 + dx1 + (int) (depth * cos(normal));
+	    Vertices[NumVertices - 1 - 2].y =
+		y0 + dy1 + (int) (depth * sin(normal));
+	    Vertices[NumVertices - 1 - 1].x =
+		x0 + dx1 + dx2 + (int) (depth * cos(normal));
+	    Vertices[NumVertices - 1 - 1].y =
+		y0 + dy1 + dy2 + (int) (depth * sin(normal));
+	    Vertices[NumVertices - 1].x = x0 + dx1 + dx2;
+	    Vertices[NumVertices - 1].y = y0 + dy1 + dy2;
+	}
 
-  MadeChanges = 1;
-  MadeMapChanges = 1;
-  }
+	MadeChanges = 1;
+	MadeMapChanges = 1;
+    }
 }
 
 
@@ -168,32 +174,33 @@
  *	The new vertices are put at (0,0).
  *	See SplitLineDefs() and MakeRectangularNook() for example of use.
  */
-static void SliceLinedef (int linedefno, int times)
+static void SliceLinedef(int linedefno, int times)
 {
-int prev_ld_no;
-for (prev_ld_no = linedefno; times > 0; times--, prev_ld_no = NumLineDefs-1)
-  {
-  int sd;
+    int prev_ld_no;
+    for (prev_ld_no = linedefno; times > 0;
+	 times--, prev_ld_no = NumLineDefs - 1)
+    {
+	int sd;
+
+	InsertObject(OBJ_VERTICES, -1, 0, 0);
+	InsertObject(OBJ_LINEDEFS, linedefno, 0, 0);
+	LineDefs[NumLineDefs - 1].start = NumVertices - 1;
+	LineDefs[NumLineDefs - 1].end = LineDefs[prev_ld_no].end;
+	LineDefs[prev_ld_no].end = NumVertices - 1;
 
-  InsertObject (OBJ_VERTICES, -1, 0, 0);
-  InsertObject (OBJ_LINEDEFS, linedefno, 0, 0);
-  LineDefs[NumLineDefs-1].start = NumVertices - 1;
-  LineDefs[NumLineDefs-1].end   = LineDefs[prev_ld_no].end;
-  LineDefs[prev_ld_no   ].end   = NumVertices - 1;
-  
-  sd = LineDefs[linedefno].sidedef1;
-  if (sd >= 0)
-    {
-    InsertObject (OBJ_SIDEDEFS, sd, 0, 0);
-    LineDefs[NumLineDefs-1].sidedef1 = NumSideDefs - 1;
+	sd = LineDefs[linedefno].sidedef1;
+	if (sd >= 0)
+	{
+	    InsertObject(OBJ_SIDEDEFS, sd, 0, 0);
+	    LineDefs[NumLineDefs - 1].sidedef1 = NumSideDefs - 1;
+	}
+	sd = LineDefs[linedefno].sidedef2;
+	if (sd >= 0)
+	{
+	    InsertObject(OBJ_SIDEDEFS, sd, 0, 0);
+	    LineDefs[NumLineDefs - 1].sidedef2 = NumSideDefs - 1;
+	}
     }
-  sd = LineDefs[linedefno].sidedef2;
-  if (sd >= 0)
-    {
-    InsertObject (OBJ_SIDEDEFS, sd, 0, 0);
-    LineDefs[NumLineDefs-1].sidedef2 = NumSideDefs - 1;
-    }
-  }
 }
 
 
@@ -201,32 +208,31 @@
  *	SetLinedefLength
  *	Move either vertex to set length of linedef to desired value
  */
-void SetLinedefLength (SelPtr obj, int length, int move_2nd_vertex)
+void SetLinedefLength(SelPtr obj, int length, int move_2nd_vertex)
 {
-SelPtr cur;
+    SelPtr cur;
 
-for (cur = obj; cur; cur = cur->next)
-  {
-  VPtr vertex1 = Vertices + LineDefs[cur->objnum].start;
-  VPtr vertex2 = Vertices + LineDefs[cur->objnum].end;
-  double angle = atan2 (vertex2->y - vertex1->y, vertex2->x - vertex1->x);
-  int dx       = (int) (length * cos (angle));
-  int dy       = (int) (length * sin (angle));
-
-  if (move_2nd_vertex)
+    for (cur = obj; cur; cur = cur->next)
     {
-    vertex2->x = vertex1->x + dx;
-    vertex2->y = vertex1->y + dy;
-    }
-  else
-    {
-    vertex1->x = vertex2->x - dx;
-    vertex1->y = vertex2->y - dy;
+	VPtr vertex1 = Vertices + LineDefs[cur->objnum].start;
+	VPtr vertex2 = Vertices + LineDefs[cur->objnum].end;
+	double angle =
+	    atan2(vertex2->y - vertex1->y, vertex2->x - vertex1->x);
+	int dx = (int) (length * cos(angle));
+	int dy = (int) (length * sin(angle));
+
+	if (move_2nd_vertex)
+	{
+	    vertex2->x = vertex1->x + dx;
+	    vertex2->y = vertex1->y + dy;
+	}
+	else
+	{
+	    vertex1->x = vertex2->x - dx;
+	    vertex1->y = vertex2->y - dy;
+	}
+
+	MadeChanges = 1;
+	MadeMapChanges = 1;
     }
-
-  MadeChanges = 1;
-  MadeMapChanges = 1;
-  }
 }
-
-
--- a/src/l_prop.cc	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/l_prop.cc	Sat Sep 24 14:16:04 2011 +0300
@@ -46,15 +46,13 @@
 /*
  *	Menu_data_ldt - Menu_data class for the linedef type
  */
-class Menu_data_ldt : public Menu_data
+class Menu_data_ldt:public Menu_data
 {
-  public :
-    Menu_data_ldt (al_llist_t *list);
-    virtual size_t nitems () const;
+    public:Menu_data_ldt(al_llist_t * list);
+    virtual size_t nitems() const;
     virtual const char *operator[] (size_t n) const;
 
-  private :
-    mutable char buf[100];
+      private: mutable char buf[100];
     al_llist_t *list;
 };
 
@@ -62,400 +60,410 @@
 /*
  *	Menu_data_ldt::Menu_data_ldt - ctor
  */
-Menu_data_ldt::Menu_data_ldt (al_llist_t *list) : list (list)
+Menu_data_ldt::Menu_data_ldt(al_llist_t * list):list(list)
 {
-  al_lrewind (this->list);
+    al_lrewind(this->list);
 }
 
 
 /*
  *	Menu_data_ldt::nitems - return the number of items
  */
-size_t Menu_data_ldt::nitems () const
+size_t Menu_data_ldt::nitems() const
 {
-  return al_lcount (list);
+    return al_lcount(list);
 }
 
 
 /*
  *	Menu_data_ldt::operator[] - return the nth item
  */
-const char *Menu_data_ldt::operator[] (size_t n) const
-{
-  if (al_lseek (list, n, SEEK_SET) != 0)
-  {
-    sprintf (buf, "BUG: al_lseek(%p, %lu): %s",
-      (void *) list, 
-      (unsigned long) n,
-      al_astrerror (al_aerrno));
-    return buf;
-  }
-  const ldtdef_t **pptr = (const ldtdef_t **) al_lptr (list);
-  if (pptr == NULL)
-    sprintf (buf, "BUG: al_lptr(%p): %s",
-      (void *) list,
-      al_astrerror (al_aerrno));
-  else
-    sprintf (buf, "%3d - %.70s", (*pptr)->number, (*pptr)->longdesc);
-  return buf;
-}
+const char *Menu_data_ldt::operator[] (size_t n)
+     const
+     {
+	 if (al_lseek(list, n, SEEK_SET) != 0)
+	 {
+	     sprintf(buf, "BUG: al_lseek(%p, %lu): %s",
+		     (void *) list,
+		     (unsigned long) n, al_astrerror(al_aerrno));
+	     return buf;
+	 }
+	 const ldtdef_t **pptr = (const ldtdef_t **) al_lptr(list);
+	 if (pptr == NULL)
+	     sprintf(buf, "BUG: al_lptr(%p): %s",
+		     (void *) list, al_astrerror(al_aerrno));
+	 else
+	     sprintf(buf, "%3d - %.70s", (*pptr)->number, (*pptr)->longdesc);
+	 return buf;
+     }
 
 
 /*
  *	Prototypes of private functions
  */
-static char *GetTaggedLineDefFlag (int linedefnum, int flagndx);
-int InputLinedefType (int x0, int y0, int *number);
-static const char *PrintLdtgroup (void *ptr);
+static char *GetTaggedLineDefFlag(int linedefnum, int flagndx);
+int InputLinedefType(int x0, int y0, int *number);
+static const char *PrintLdtgroup(void *ptr);
 
 
-void LinedefProperties (int x0, int y0, SelPtr obj)
+void LinedefProperties(int x0, int y0, SelPtr obj)
 {
-  char  *menustr[8];
-  char   texname[WAD_TEX_NAME + 1];
-  int    n, val;
-  SelPtr cur, sdlist;
-  int objtype = OBJ_LINEDEFS;
-  int    subwin_y0;
-  int    subsubwin_y0;
+    char *menustr[8];
+    char texname[WAD_TEX_NAME + 1];
+    int n, val;
+    SelPtr cur, sdlist;
+    int objtype = OBJ_LINEDEFS;
+    int subwin_y0;
+    int subsubwin_y0;
 
-  {
-    bool sd1 = LineDefs[obj->objnum].sidedef1 >= 0;
-    bool sd2 = LineDefs[obj->objnum].sidedef2 >= 0;
-    val = vDisplayMenu (x0, y0, "Choose the object to edit:",
-       "Edit the linedef",					YK_, 0,
-       sd1 ? "Edit the 1st sidedef" : "Add a 1st sidedef",	YK_, 0,
-       sd2 ? "Edit the 2nd sidedef" : "Add a 2nd sidedef",	YK_, 0,
-       NULL);
-  }
-  subwin_y0 = y0 + BOX_BORDER + (2 + val) * FONTH;
-  switch (val)
-  {
+    {
+	bool sd1 = LineDefs[obj->objnum].sidedef1 >= 0;
+	bool sd2 = LineDefs[obj->objnum].sidedef2 >= 0;
+	val = vDisplayMenu(x0, y0, "Choose the object to edit:",
+			   "Edit the linedef", YK_, 0,
+			   sd1 ? "Edit the 1st sidedef" : "Add a 1st sidedef",
+			   YK_, 0,
+			   sd2 ? "Edit the 2nd sidedef" : "Add a 2nd sidedef",
+			   YK_, 0, NULL);
+    }
+    subwin_y0 = y0 + BOX_BORDER + (2 + val) * FONTH;
+    switch (val)
+    {
     case 1:
-      for (n = 0; n < 8; n++)
-	menustr[n] = (char *) GetMemory (60);
-      sprintf (menustr[7], "Edit linedef #%d", obj->objnum);
-      sprintf (menustr[0], "Change flags            (Current: %d)",
-	LineDefs[obj->objnum].flags);
-      sprintf (menustr[1], "Change type             (Current: %d)",
-	LineDefs[obj->objnum].type);
-      sprintf (menustr[2], "Change sector tag       (Current: %d)",
-	LineDefs[obj->objnum].tag);
-      sprintf (menustr[3], "Change starting vertex  (Current: #%d)",
-	LineDefs[obj->objnum].start);
-      sprintf (menustr[4], "Change ending vertex    (Current: #%d)",
-	LineDefs[obj->objnum].end);
-      sprintf (menustr[5], "Change 1st sidedef ref. (Current: #%d)",
-	LineDefs[obj->objnum].sidedef1);
-      sprintf (menustr[6], "Change 2nd sidedef ref. (Current: #%d)",
-	LineDefs[obj->objnum].sidedef2);
-      val = vDisplayMenu (x0 + 42, subwin_y0, menustr[7],
-	menustr[0], YK_, 0,
-	menustr[1], YK_, 0,
-	menustr[2], YK_, 0,
-	menustr[3], YK_, 0,
-	menustr[4], YK_, 0,
-	menustr[5], YK_, 0,
-	menustr[6], YK_, 0,
-	NULL);
-      for (n = 0; n < 8; n++)
-	FreeMemory (menustr[n]);
-      subsubwin_y0 = subwin_y0 + BOX_BORDER + (2 + val) * FONTH;
-      switch (val)
-      {
+	for (n = 0; n < 8; n++)
+	    menustr[n] = (char *) GetMemory(60);
+	sprintf(menustr[7], "Edit linedef #%d", obj->objnum);
+	sprintf(menustr[0], "Change flags            (Current: %d)",
+		LineDefs[obj->objnum].flags);
+	sprintf(menustr[1], "Change type             (Current: %d)",
+		LineDefs[obj->objnum].type);
+	sprintf(menustr[2], "Change sector tag       (Current: %d)",
+		LineDefs[obj->objnum].tag);
+	sprintf(menustr[3], "Change starting vertex  (Current: #%d)",
+		LineDefs[obj->objnum].start);
+	sprintf(menustr[4], "Change ending vertex    (Current: #%d)",
+		LineDefs[obj->objnum].end);
+	sprintf(menustr[5], "Change 1st sidedef ref. (Current: #%d)",
+		LineDefs[obj->objnum].sidedef1);
+	sprintf(menustr[6], "Change 2nd sidedef ref. (Current: #%d)",
+		LineDefs[obj->objnum].sidedef2);
+	val = vDisplayMenu(x0 + 42, subwin_y0, menustr[7],
+			   menustr[0], YK_, 0,
+			   menustr[1], YK_, 0,
+			   menustr[2], YK_, 0,
+			   menustr[3], YK_, 0,
+			   menustr[4], YK_, 0,
+			   menustr[5], YK_, 0, menustr[6], YK_, 0, NULL);
+	for (n = 0; n < 8; n++)
+	    FreeMemory(menustr[n]);
+	subsubwin_y0 = subwin_y0 + BOX_BORDER + (2 + val) * FONTH;
+	switch (val)
+	{
 	case 1:
-	  val = vDisplayMenu (x0 + 84, subsubwin_y0, "Toggle the flags:",
-	    GetTaggedLineDefFlag (obj->objnum, 1),  YK_, 0,
-	    GetTaggedLineDefFlag (obj->objnum, 2),  YK_, 0,
-	    GetTaggedLineDefFlag (obj->objnum, 3),  YK_, 0,
-	    GetTaggedLineDefFlag (obj->objnum, 4),  YK_, 0,
-	    GetTaggedLineDefFlag (obj->objnum, 5),  YK_, 0,
-	    GetTaggedLineDefFlag (obj->objnum, 6),  YK_, 0,
-	    GetTaggedLineDefFlag (obj->objnum, 7),  YK_, 0,
-	    GetTaggedLineDefFlag (obj->objnum, 8),  YK_, 0,
-	    GetTaggedLineDefFlag (obj->objnum, 9),  YK_, 0,
-	    GetTaggedLineDefFlag (obj->objnum, 10), YK_, 0,
-	    GetTaggedLineDefFlag (obj->objnum, 11), YK_, 0,
-	    GetTaggedLineDefFlag (obj->objnum, 12), YK_, 0,
-	    GetTaggedLineDefFlag (obj->objnum, 13), YK_, 0,
-	    GetTaggedLineDefFlag (obj->objnum, 14), YK_, 0,
-	    GetTaggedLineDefFlag (obj->objnum, 15), YK_, 0,
-	    GetTaggedLineDefFlag (obj->objnum, 16), YK_, 0,
-	    "(Enter a decimal value)", YK_, 0,
-	    NULL);
-	  if (val >= 1 && val <= 16)
-	     {
-	     for (cur = obj; cur; cur = cur->next)
-		LineDefs[cur->objnum].flags ^= 0x01 << (val - 1);
-	     MadeChanges = 1;
-	     }
-	  else if (val == 17)
-	     {
-	     val = InputIntegerValue (x0 + 126, subsubwin_y0 + 12 * FONTH,
-		0, 65535, LineDefs[obj->objnum].flags);
-	     if (val != IIV_CANCEL)
+	    val = vDisplayMenu(x0 + 84, subsubwin_y0, "Toggle the flags:",
+			       GetTaggedLineDefFlag(obj->objnum, 1), YK_, 0,
+			       GetTaggedLineDefFlag(obj->objnum, 2), YK_, 0,
+			       GetTaggedLineDefFlag(obj->objnum, 3), YK_, 0,
+			       GetTaggedLineDefFlag(obj->objnum, 4), YK_, 0,
+			       GetTaggedLineDefFlag(obj->objnum, 5), YK_, 0,
+			       GetTaggedLineDefFlag(obj->objnum, 6), YK_, 0,
+			       GetTaggedLineDefFlag(obj->objnum, 7), YK_, 0,
+			       GetTaggedLineDefFlag(obj->objnum, 8), YK_, 0,
+			       GetTaggedLineDefFlag(obj->objnum, 9), YK_, 0,
+			       GetTaggedLineDefFlag(obj->objnum, 10), YK_, 0,
+			       GetTaggedLineDefFlag(obj->objnum, 11), YK_, 0,
+			       GetTaggedLineDefFlag(obj->objnum, 12), YK_, 0,
+			       GetTaggedLineDefFlag(obj->objnum, 13), YK_, 0,
+			       GetTaggedLineDefFlag(obj->objnum, 14), YK_, 0,
+			       GetTaggedLineDefFlag(obj->objnum, 15), YK_, 0,
+			       GetTaggedLineDefFlag(obj->objnum, 16), YK_, 0,
+			       "(Enter a decimal value)", YK_, 0, NULL);
+	    if (val >= 1 && val <= 16)
+	    {
+		for (cur = obj; cur; cur = cur->next)
+		    LineDefs[cur->objnum].flags ^= 0x01 << (val - 1);
+		MadeChanges = 1;
+	    }
+	    else if (val == 17)
+	    {
+		val = InputIntegerValue(x0 + 126, subsubwin_y0 + 12 * FONTH,
+					0, 65535,
+					LineDefs[obj->objnum].flags);
+		if (val != IIV_CANCEL)
 		{
-		for (cur = obj; cur; cur = cur->next)
-		   LineDefs[cur->objnum].flags = val;
-		MadeChanges = 1;
+		    for (cur = obj; cur; cur = cur->next)
+			LineDefs[cur->objnum].flags = val;
+		    MadeChanges = 1;
 		}
-	     }
-	  break;
+	    }
+	    break;
 
 	case 2:
-	  if (! InputLinedefType (x0, subsubwin_y0, &val))
-	  {
-	    for (cur = obj; cur; cur = cur->next)
-	      LineDefs[cur->objnum].type = val;
-	    MadeChanges = 1;
-	  }
-	  break;
+	    if (!InputLinedefType(x0, subsubwin_y0, &val))
+	    {
+		for (cur = obj; cur; cur = cur->next)
+		    LineDefs[cur->objnum].type = val;
+		MadeChanges = 1;
+	    }
+	    break;
 
 	case 3:
-	  val = InputIntegerValue (x0 + 84, subsubwin_y0,
-	    -32768, 32767, LineDefs[obj->objnum].tag);
-	  if (val != IIV_CANCEL)  // Not [esc]
-	  {
-	    for (cur = obj; cur; cur = cur->next)
-	      LineDefs[cur->objnum].tag = val;
-	    MadeChanges = 1;
-	  }
-	  break;
+	    val = InputIntegerValue(x0 + 84, subsubwin_y0,
+				    -32768, 32767, LineDefs[obj->objnum].tag);
+	    if (val != IIV_CANCEL)	// Not [esc]
+	    {
+		for (cur = obj; cur; cur = cur->next)
+		    LineDefs[cur->objnum].tag = val;
+		MadeChanges = 1;
+	    }
+	    break;
 
 	case 4:
-	  val = InputObjectXRef (x0 + 84, subsubwin_y0,
-	    OBJ_VERTICES, 0, LineDefs[obj->objnum].start);
-	  if (val >= 0)
-	  {
-	    for (cur = obj; cur; cur = cur->next)
-	      LineDefs[cur->objnum].start = val;
-	    MadeChanges = 1;
-	    MadeMapChanges = 1;
-	  }
-	  break;
+	    val = InputObjectXRef(x0 + 84, subsubwin_y0,
+				  OBJ_VERTICES, 0,
+				  LineDefs[obj->objnum].start);
+	    if (val >= 0)
+	    {
+		for (cur = obj; cur; cur = cur->next)
+		    LineDefs[cur->objnum].start = val;
+		MadeChanges = 1;
+		MadeMapChanges = 1;
+	    }
+	    break;
 
 	case 5:
-	  val = InputObjectXRef (x0 + 84, subsubwin_y0,
-	    OBJ_VERTICES, 0, LineDefs[obj->objnum].end);
-	  if (val >= 0)
-	  {
-	    for (cur = obj; cur; cur = cur->next)
-	      LineDefs[cur->objnum].end = val;
-	    MadeChanges = 1;
-	    MadeMapChanges = 1;
-	  }
-	  break;
+	    val = InputObjectXRef(x0 + 84, subsubwin_y0,
+				  OBJ_VERTICES, 0, LineDefs[obj->objnum].end);
+	    if (val >= 0)
+	    {
+		for (cur = obj; cur; cur = cur->next)
+		    LineDefs[cur->objnum].end = val;
+		MadeChanges = 1;
+		MadeMapChanges = 1;
+	    }
+	    break;
 
 	case 6:
-	  val = InputObjectXRef (x0 + 84, subsubwin_y0,
-	    OBJ_SIDEDEFS, 1, LineDefs[obj->objnum].sidedef1);
-	  if (val >= -1)
-	  {
-	    for (cur = obj; cur; cur = cur->next)
-	      LineDefs[cur->objnum].sidedef1 = val;
-	    MadeChanges = 1;
-	    MadeMapChanges = 1;
-	  }
-	  break;
+	    val = InputObjectXRef(x0 + 84, subsubwin_y0,
+				  OBJ_SIDEDEFS, 1,
+				  LineDefs[obj->objnum].sidedef1);
+	    if (val >= -1)
+	    {
+		for (cur = obj; cur; cur = cur->next)
+		    LineDefs[cur->objnum].sidedef1 = val;
+		MadeChanges = 1;
+		MadeMapChanges = 1;
+	    }
+	    break;
 
 	case 7:
-	  val = InputObjectXRef (x0 + 84, subsubwin_y0,
-	    OBJ_SIDEDEFS, 1, LineDefs[obj->objnum].sidedef2);
-	  if (val >= -1)
-	  {
-	    for (cur = obj; cur; cur = cur->next)
-	      LineDefs[cur->objnum].sidedef2 = val;
-	    MadeChanges = 1;
-	    MadeMapChanges = 1;
-	  }
-	  break;
-     }
-     break;
+	    val = InputObjectXRef(x0 + 84, subsubwin_y0,
+				  OBJ_SIDEDEFS, 1,
+				  LineDefs[obj->objnum].sidedef2);
+	    if (val >= -1)
+	    {
+		for (cur = obj; cur; cur = cur->next)
+		    LineDefs[cur->objnum].sidedef2 = val;
+		MadeChanges = 1;
+		MadeMapChanges = 1;
+	    }
+	    break;
+	}
+	break;
 
-    // Edit or add the first sidedef
+	// Edit or add the first sidedef
     case 2:
-      if (LineDefs[obj->objnum].sidedef1 >= 0)
-      {
-	// Build a new selection list with the first sidedefs
-	objtype = OBJ_SIDEDEFS;
-	sdlist = 0;
-	for (cur = obj; cur; cur = cur->next)
-	  if (LineDefs[cur->objnum].sidedef1 >= 0)
-	    SelectObject (&sdlist, LineDefs[cur->objnum].sidedef1);
-      }
-      else
-      {
-	// Add a new first sidedef
-	for (cur = obj; cur; cur = cur->next)
-	  if (LineDefs[cur->objnum].sidedef1 == -1)
-	  {
-	    InsertObject (OBJ_SIDEDEFS, -1, 0, 0);
-	    LineDefs[cur->objnum].sidedef1 = NumSideDefs - 1;
-	  }
-	break;
-      }
-      // FALL THROUGH
-
-    // Edit or add the second sidedef
-    case 3:
-      if (objtype != OBJ_SIDEDEFS)
-      {
-	if (LineDefs[obj->objnum].sidedef2 >= 0)
+	if (LineDefs[obj->objnum].sidedef1 >= 0)
 	{
-	  // Build a new selection list with the second (or first) SideDefs
-	  objtype = OBJ_SIDEDEFS;
-	  sdlist = 0;
-	  for (cur = obj; cur; cur = cur->next)
-	    if (LineDefs[cur->objnum].sidedef2 >= 0)
-	      SelectObject (&sdlist, LineDefs[cur->objnum].sidedef2);
-	    else if (LineDefs[cur->objnum].sidedef1 >= 0)
-	      SelectObject (&sdlist, LineDefs[cur->objnum].sidedef1);
+	    // Build a new selection list with the first sidedefs
+	    objtype = OBJ_SIDEDEFS;
+	    sdlist = 0;
+	    for (cur = obj; cur; cur = cur->next)
+		if (LineDefs[cur->objnum].sidedef1 >= 0)
+		    SelectObject(&sdlist, LineDefs[cur->objnum].sidedef1);
 	}
 	else
 	{
-	  // Add a new second (or first) sidedef
-	  for (cur = obj; cur; cur = cur->next)
-	    if (LineDefs[cur->objnum].sidedef1 == -1)
-	    {
-	      InsertObject (OBJ_SIDEDEFS, -1, 0, 0);
-	      LineDefs[cur->objnum].sidedef1 = NumSideDefs - 1;
-	    }
-	    else if (LineDefs[cur->objnum].sidedef2 == -1)
-	    {
-	      n = LineDefs[cur->objnum].sidedef1;
-	      InsertObject (OBJ_SIDEDEFS, -1, 0, 0);
-	      strncpy (SideDefs[NumSideDefs - 1].tex3, "-", WAD_TEX_NAME);
-	      strncpy (SideDefs[n].tex3, "-", WAD_TEX_NAME);
-	      LineDefs[cur->objnum].sidedef2 = NumSideDefs - 1;
-	      LineDefs[cur->objnum].flags ^= 4;  // Set the 2S bit
-	      LineDefs[cur->objnum].flags &= ~1;  // Clear the Im bit
-	    }
-	  break;
+	    // Add a new first sidedef
+	    for (cur = obj; cur; cur = cur->next)
+		if (LineDefs[cur->objnum].sidedef1 == -1)
+		{
+		    InsertObject(OBJ_SIDEDEFS, -1, 0, 0);
+		    LineDefs[cur->objnum].sidedef1 = NumSideDefs - 1;
+		}
+	    break;
 	}
-      }
-      for (n = 0; n < 7; n++)
-	menustr[n] = (char *) GetMemory (60);
-      sprintf (menustr[6], "Edit sidedef #%d", sdlist->objnum);
-      texname[WAD_TEX_NAME] = '\0';
-      strncpy (texname, SideDefs[sdlist->objnum].tex3, WAD_TEX_NAME);
-      sprintf (menustr[0], "Change middle texture   (Current: %s)", texname);
-      strncpy (texname, SideDefs[sdlist->objnum].tex1, WAD_TEX_NAME);
-      sprintf (menustr[1], "Change upper texture    (Current: %s)", texname);
-      strncpy (texname, SideDefs[sdlist->objnum].tex2, WAD_TEX_NAME);
-      sprintf (menustr[2], "Change lower texture    (Current: %s)", texname);
-      sprintf (menustr[3], "Change texture X offset (Current: %d)",
-	SideDefs[sdlist->objnum].xoff);
-      sprintf (menustr[4], "Change texture Y offset (Current: %d)",
-	SideDefs[sdlist->objnum].yoff);
-      sprintf (menustr[5], "Change sector ref.      (Current: #%d)",
-	SideDefs[sdlist->objnum].sector);
-      val = vDisplayMenu (x0 + 42, subwin_y0, menustr[6],
-	menustr[0], YK_, 0,
-	menustr[1], YK_, 0,
-	menustr[2], YK_, 0,
-	menustr[3], YK_, 0,
-	menustr[4], YK_, 0,
-	menustr[5], YK_, 0,
-	NULL);
-      for (n = 0; n < 7; n++)
-	FreeMemory (menustr[n]);
-      subsubwin_y0 = subwin_y0 + BOX_BORDER + (2 + val) * FONTH;
-      switch (val)
-      {
+	// FALL THROUGH
+
+	// Edit or add the second sidedef
+    case 3:
+	if (objtype != OBJ_SIDEDEFS)
+	{
+	    if (LineDefs[obj->objnum].sidedef2 >= 0)
+	    {
+		// Build a new selection list with the second (or first) SideDefs
+		objtype = OBJ_SIDEDEFS;
+		sdlist = 0;
+		for (cur = obj; cur; cur = cur->next)
+		    if (LineDefs[cur->objnum].sidedef2 >= 0)
+			SelectObject(&sdlist, LineDefs[cur->objnum].sidedef2);
+		    else if (LineDefs[cur->objnum].sidedef1 >= 0)
+			SelectObject(&sdlist, LineDefs[cur->objnum].sidedef1);
+	    }
+	    else
+	    {
+		// Add a new second (or first) sidedef
+		for (cur = obj; cur; cur = cur->next)
+		    if (LineDefs[cur->objnum].sidedef1 == -1)
+		    {
+			InsertObject(OBJ_SIDEDEFS, -1, 0, 0);
+			LineDefs[cur->objnum].sidedef1 = NumSideDefs - 1;
+		    }
+		    else if (LineDefs[cur->objnum].sidedef2 == -1)
+		    {
+			n = LineDefs[cur->objnum].sidedef1;
+			InsertObject(OBJ_SIDEDEFS, -1, 0, 0);
+			strncpy(SideDefs[NumSideDefs - 1].tex3, "-",
+				WAD_TEX_NAME);
+			strncpy(SideDefs[n].tex3, "-", WAD_TEX_NAME);
+			LineDefs[cur->objnum].sidedef2 = NumSideDefs - 1;
+			LineDefs[cur->objnum].flags ^= 4;	// Set the 2S bit
+			LineDefs[cur->objnum].flags &= ~1;	// Clear the Im bit
+		    }
+		break;
+	    }
+	}
+	for (n = 0; n < 7; n++)
+	    menustr[n] = (char *) GetMemory(60);
+	sprintf(menustr[6], "Edit sidedef #%d", sdlist->objnum);
+	texname[WAD_TEX_NAME] = '\0';
+	strncpy(texname, SideDefs[sdlist->objnum].tex3, WAD_TEX_NAME);
+	sprintf(menustr[0], "Change middle texture   (Current: %s)", texname);
+	strncpy(texname, SideDefs[sdlist->objnum].tex1, WAD_TEX_NAME);
+	sprintf(menustr[1], "Change upper texture    (Current: %s)", texname);
+	strncpy(texname, SideDefs[sdlist->objnum].tex2, WAD_TEX_NAME);
+	sprintf(menustr[2], "Change lower texture    (Current: %s)", texname);
+	sprintf(menustr[3], "Change texture X offset (Current: %d)",
+		SideDefs[sdlist->objnum].xoff);
+	sprintf(menustr[4], "Change texture Y offset (Current: %d)",
+		SideDefs[sdlist->objnum].yoff);
+	sprintf(menustr[5], "Change sector ref.      (Current: #%d)",
+		SideDefs[sdlist->objnum].sector);
+	val = vDisplayMenu(x0 + 42, subwin_y0, menustr[6],
+			   menustr[0], YK_, 0,
+			   menustr[1], YK_, 0,
+			   menustr[2], YK_, 0,
+			   menustr[3], YK_, 0,
+			   menustr[4], YK_, 0, menustr[5], YK_, 0, NULL);
+	for (n = 0; n < 7; n++)
+	    FreeMemory(menustr[n]);
+	subsubwin_y0 = subwin_y0 + BOX_BORDER + (2 + val) * FONTH;
+	switch (val)
+	{
 	case 1:
-	  strncpy (texname, SideDefs[sdlist->objnum].tex3, WAD_TEX_NAME);
-	  ChooseWallTexture (x0 + 84, subsubwin_y0 ,
-	    "Choose a wall texture", NumWTexture, WTexture, texname);
-	  if (strlen (texname) > 0)
-	  {
-	    for (cur = sdlist; cur; cur = cur->next)
-	      if (cur->objnum >= 0)
-		strncpy (SideDefs[cur->objnum].tex3, texname, WAD_TEX_NAME);
-	    MadeChanges = 1;
-	  }
-	  break;
+	    strncpy(texname, SideDefs[sdlist->objnum].tex3, WAD_TEX_NAME);
+	    ChooseWallTexture(x0 + 84, subsubwin_y0,
+			      "Choose a wall texture", NumWTexture, WTexture,
+			      texname);
+	    if (strlen(texname) > 0)
+	    {
+		for (cur = sdlist; cur; cur = cur->next)
+		    if (cur->objnum >= 0)
+			strncpy(SideDefs[cur->objnum].tex3, texname,
+				WAD_TEX_NAME);
+		MadeChanges = 1;
+	    }
+	    break;
 
 	case 2:
-	  strncpy (texname, SideDefs[sdlist->objnum].tex1, WAD_TEX_NAME);
-	  ChooseWallTexture (x0 + 84, subsubwin_y0,
-	     "Choose a wall texture", NumWTexture, WTexture, texname);
-	  if (strlen (texname) > 0)
-	  {
-	    for (cur = sdlist; cur; cur = cur->next)
-	      if (cur->objnum >= 0)
-		strncpy (SideDefs[cur->objnum].tex1, texname, WAD_TEX_NAME);
-	    MadeChanges = 1;
-	  }
-	  break;
+	    strncpy(texname, SideDefs[sdlist->objnum].tex1, WAD_TEX_NAME);
+	    ChooseWallTexture(x0 + 84, subsubwin_y0,
+			      "Choose a wall texture", NumWTexture, WTexture,
+			      texname);
+	    if (strlen(texname) > 0)
+	    {
+		for (cur = sdlist; cur; cur = cur->next)
+		    if (cur->objnum >= 0)
+			strncpy(SideDefs[cur->objnum].tex1, texname,
+				WAD_TEX_NAME);
+		MadeChanges = 1;
+	    }
+	    break;
 
 	case 3:
-	  strncpy (texname, SideDefs[sdlist->objnum].tex2, WAD_TEX_NAME);
-	  ChooseWallTexture (x0 + 84, subsubwin_y0,
-	    "Choose a wall texture", NumWTexture, WTexture, texname);
-	  if (strlen (texname) > 0)
-	  {
-	    for (cur = sdlist; cur; cur = cur->next)
-	      if (cur->objnum >= 0)
-		strncpy (SideDefs[cur->objnum].tex2, texname, WAD_TEX_NAME);
-	    MadeChanges = 1;
-	  }
-	  break;
+	    strncpy(texname, SideDefs[sdlist->objnum].tex2, WAD_TEX_NAME);
+	    ChooseWallTexture(x0 + 84, subsubwin_y0,
+			      "Choose a wall texture", NumWTexture, WTexture,
+			      texname);
+	    if (strlen(texname) > 0)
+	    {
+		for (cur = sdlist; cur; cur = cur->next)
+		    if (cur->objnum >= 0)
+			strncpy(SideDefs[cur->objnum].tex2, texname,
+				WAD_TEX_NAME);
+		MadeChanges = 1;
+	    }
+	    break;
 
 	case 4:
-	  val = InputIntegerValue (x0 + 84, subsubwin_y0,
-	    -32768, 32767, SideDefs[sdlist->objnum].xoff);
-	  if (val != IIV_CANCEL)
-	  {
-	    for (cur = sdlist; cur; cur = cur->next)
-	      if (cur->objnum >= 0)
-		SideDefs[cur->objnum].xoff = val;
-	    MadeChanges = 1;
-	  }
-	  break;
+	    val = InputIntegerValue(x0 + 84, subsubwin_y0,
+				    -32768, 32767,
+				    SideDefs[sdlist->objnum].xoff);
+	    if (val != IIV_CANCEL)
+	    {
+		for (cur = sdlist; cur; cur = cur->next)
+		    if (cur->objnum >= 0)
+			SideDefs[cur->objnum].xoff = val;
+		MadeChanges = 1;
+	    }
+	    break;
 
 	case 5:
-	  val = InputIntegerValue (x0 + 84, subsubwin_y0,
-	    -32768, 32767, SideDefs[sdlist->objnum].yoff);
-	  if (val != IIV_CANCEL)
-	  {
-	    for (cur = sdlist; cur; cur = cur->next)
-	      if (cur->objnum >= 0)
-		SideDefs[cur->objnum].yoff = val;
-	    MadeChanges = 1;
-	  }
-	  break;
+	    val = InputIntegerValue(x0 + 84, subsubwin_y0,
+				    -32768, 32767,
+				    SideDefs[sdlist->objnum].yoff);
+	    if (val != IIV_CANCEL)
+	    {
+		for (cur = sdlist; cur; cur = cur->next)
+		    if (cur->objnum >= 0)
+			SideDefs[cur->objnum].yoff = val;
+		MadeChanges = 1;
+	    }
+	    break;
 
 	case 6:
-	  val = InputObjectXRef (x0 + 84, subsubwin_y0,
-	    OBJ_SECTORS, 0, SideDefs[sdlist->objnum].sector);
-	  if (val >= 0)
-	  {
-	    for (cur = sdlist; cur; cur = cur->next)
-	      if (cur->objnum >= 0)
-		SideDefs[cur->objnum].sector = val;
-	    MadeChanges = 1;
-	  }
-	  break;
-      }
-      ForgetSelection (&sdlist);
-      break;
-  }
+	    val = InputObjectXRef(x0 + 84, subsubwin_y0,
+				  OBJ_SECTORS, 0,
+				  SideDefs[sdlist->objnum].sector);
+	    if (val >= 0)
+	    {
+		for (cur = sdlist; cur; cur = cur->next)
+		    if (cur->objnum >= 0)
+			SideDefs[cur->objnum].sector = val;
+		MadeChanges = 1;
+	    }
+	    break;
+	}
+	ForgetSelection(&sdlist);
+	break;
+    }
 }
 
 
 /*
 */
 
-static char *GetTaggedLineDefFlag (int linedefnum, int flagndx)
+static char *GetTaggedLineDefFlag(int linedefnum, int flagndx)
 {
-  static char ldstr[16][50];
+    static char ldstr[16][50];
 
-  if ((LineDefs[linedefnum].flags & (0x01 << (flagndx - 1))) != 0)
-    strcpy (ldstr[flagndx - 1], "* ");
-  else
-    strcpy (ldstr[flagndx - 1], "  ");
-  strcat (ldstr[flagndx - 1], GetLineDefFlagsLongName (0x01 << (flagndx - 1)));
-  return ldstr[flagndx - 1];
+    if ((LineDefs[linedefnum].flags & (0x01 << (flagndx - 1))) != 0)
+	strcpy(ldstr[flagndx - 1], "* ");
+    else
+	strcpy(ldstr[flagndx - 1], "  ");
+    strcat(ldstr[flagndx - 1],
+	   GetLineDefFlagsLongName(0x01 << (flagndx - 1)));
+    return ldstr[flagndx - 1];
 }
 
 
@@ -465,64 +473,66 @@
  *	Let the user select a linedef type number and return it.
  *	Returns 0 if OK, <>0 if cancelled
  */
-int InputLinedefType (int x0, int y0, int *number)
+int InputLinedefType(int x0, int y0, int *number)
 {
-  int         r;
-  int         ldtgno = 0;
-  char        ldtg; 
-  al_llist_t *list = 0;
+    int r;
+    int ldtgno = 0;
+    char ldtg;
+    al_llist_t *list = 0;
+
+    for (;;)
+    {
+	/* First let user select a ldtgroup */
+	if (DisplayMenuList(x0 + 84, y0, "Select group", ldtgroup,
+			    PrintLdtgroup, &ldtgno) < 0)
+	    return 1;
+	if (al_lseek(ldtgroup, ldtgno, SEEK_SET))
+	    fatal_error("%s ILT1 (%s)", msg_unexpected,
+			al_astrerror(al_aerrno));
+	ldtg = CUR_LDTGROUP->ldtgroup;
 
-  for (;;)
-  {
-    /* First let user select a ldtgroup */
-    if (DisplayMenuList (x0+84, y0, "Select group", ldtgroup,
-     PrintLdtgroup, &ldtgno) < 0)
-      return 1;
-    if (al_lseek (ldtgroup, ldtgno, SEEK_SET))
-      fatal_error ("%s ILT1 (%s)", msg_unexpected, al_astrerror (al_aerrno));
-    ldtg = CUR_LDTGROUP->ldtgroup;
+	/* KLUDGE: Special ldtgroup LDT_FREE means "enter number"
+	   Don't look for this ldtgroup in the .ygd file :
+	   LoadGameDefs() creates it manually. */
+	if (ldtg == LDT_FREE)
+	{
+	    // FIXME should be unsigned
+	    *number = InputIntegerValue(x0 + 126, y0 + (3 + ldtgno) * FONTH,
+					-32768, 32767, 0);
+	    if (*number != IIV_CANCEL)
+		break;
+	    goto again;
+	}
 
-    /* KLUDGE: Special ldtgroup LDT_FREE means "enter number"
-       Don't look for this ldtgroup in the .ygd file :
-       LoadGameDefs() creates it manually. */
-    if (ldtg == LDT_FREE)
-    {
-      // FIXME should be unsigned
-      *number = InputIntegerValue (x0+126, y0 + (3 + ldtgno) * FONTH,
-	 -32768, 32767, 0);
-      if (*number != IIV_CANCEL)
+	/* Then build a list of pointers on all ldt that have this
+	   ldtgroup and let user select one */
+	list = al_lcreate(sizeof(void *));
+	for (al_lrewind(ldtdef); !al_leol(ldtdef); al_lstep(ldtdef))
+	    if (CUR_LDTDEF->ldtgroup == ldtg)
+	    {
+		void *ptr = CUR_LDTDEF;
+		al_lwrite(list, &ptr);
+	    }
+	{
+	    Menu_data_ldt menudata(list);
+	    r = DisplayMenuList
+		(x0 + 126, y0 + 2 * FONTH, "Select type", menudata, NULL);
+	}
+	if (r < 0)
+	    goto again;
+	if (al_lseek(list, r, SEEK_SET))
+	    fatal_error("%s ILT2 (%s)", msg_unexpected,
+			al_astrerror(al_aerrno));
+	*number = (*((ldtdef_t **) al_lptr(list)))->number;
+	al_ldiscard(list);
 	break;
-      goto again;
+
+      again:
+	;
+	/* draw_map (OBJ_THINGS, 0, 0);  FIXME! */
     }
-      
-    /* Then build a list of pointers on all ldt that have this
-       ldtgroup and let user select one */
-    list = al_lcreate (sizeof (void *));
-    for (al_lrewind (ldtdef); ! al_leol (ldtdef); al_lstep (ldtdef))
-      if (CUR_LDTDEF->ldtgroup == ldtg)
-      {
-	void *ptr = CUR_LDTDEF;
-	al_lwrite (list, &ptr);
-      }
-    {
-      Menu_data_ldt menudata (list);
-      r = DisplayMenuList
-       (x0+126, y0 + 2 * FONTH, "Select type", menudata, NULL);
-    }
-    if (r < 0)
-      goto again;
-    if (al_lseek (list, r, SEEK_SET))
-      fatal_error ("%s ILT2 (%s)", msg_unexpected, al_astrerror (al_aerrno));
-    *number = (*((ldtdef_t **) al_lptr (list)))->number;
-    al_ldiscard (list);
-    break;
 
-    again :
-    ;
-    /* draw_map (OBJ_THINGS, 0, 0);  FIXME! */
-  }
-
-  return 0;
+    return 0;
 }
 
 
@@ -530,11 +540,11 @@
  *	PrintLdtgroup
  *	Used by DisplayMenuList when called by InputLinedefType
  */
-static const char *PrintLdtgroup (void *ptr)
+static const char *PrintLdtgroup(void *ptr)
 {
-  if (! ptr)
-    return "PrintLdtgroup: (null)";
-  return ((ldtgroup_t *)ptr)->desc;
+    if (!ptr)
+	return "PrintLdtgroup: (null)";
+    return ((ldtgroup_t *) ptr)->desc;
 }
 
 /*
@@ -550,24 +560,24 @@
  */
 #define LINEDEF_FLAG_KEEP  (1 + 4)
 
-void TransferLinedefProperties (int src_linedef, SelPtr linedefs)
+void TransferLinedefProperties(int src_linedef, SelPtr linedefs)
 {
-   SelPtr cur;
-   wad_ldflags_t src_flags = LineDefs[src_linedef].flags & ~LINEDEF_FLAG_KEEP;
+    SelPtr cur;
+    wad_ldflags_t src_flags =
+	LineDefs[src_linedef].flags & ~LINEDEF_FLAG_KEEP;
 
-   for (cur=linedefs; cur; cur=cur->next)
-   {
-      if (! is_obj(cur->objnum))
-         continue;
+    for (cur = linedefs; cur; cur = cur->next)
+    {
+	if (!is_obj(cur->objnum))
+	    continue;
 
-      // don't transfer certain flags
-      LineDefs[cur->objnum].flags &= LINEDEF_FLAG_KEEP;
-      LineDefs[cur->objnum].flags |= src_flags;
+	// don't transfer certain flags
+	LineDefs[cur->objnum].flags &= LINEDEF_FLAG_KEEP;
+	LineDefs[cur->objnum].flags |= src_flags;
 
-      LineDefs[cur->objnum].type = LineDefs[src_linedef].type;
-      LineDefs[cur->objnum].tag  = LineDefs[src_linedef].tag;
+	LineDefs[cur->objnum].type = LineDefs[src_linedef].type;
+	LineDefs[cur->objnum].tag = LineDefs[src_linedef].tag;
 
-      MadeChanges = 1;
-   }
+	MadeChanges = 1;
+    }
 }
-
--- a/src/l_super.h	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/l_super.h	Sat Sep 24 14:16:04 2011 +0300
@@ -20,7 +20,7 @@
 */
 
 
-#ifndef YH_L_SUPER  /* DO NOT INSERT ANYTHING BEFORE THIS LINE */
+#ifndef YH_L_SUPER		/* DO NOT INSERT ANYTHING BEFORE THIS LINE */
 #define YH_L_SUPER
 
 #include "levels.h"
@@ -40,21 +40,21 @@
 class Superimposed_ld
 {
   public:
-             Superimposed_ld ();
-    int      set             (obj_no_t);
-    obj_no_t get             ();
-    void     rewind          ();
+    Superimposed_ld();
+    int set(obj_no_t);
+    obj_no_t get();
+    void rewind();
 
   private:
-    obj_no_t refldno;			// Reference linedef
-    obj_no_t ldno;			// get() will start from there
+      obj_no_t refldno;		// Reference linedef
+    obj_no_t ldno;		// get() will start from there
 };
 
 
-inline Superimposed_ld::Superimposed_ld ()
+inline Superimposed_ld::Superimposed_ld()
 {
-  refldno = -1;
-  rewind ();
+    refldno = -1;
+    rewind();
 }
 
 
@@ -65,14 +65,14 @@
  *	returns a non-zero value. Otherwise, set the linedef number,
  *	calls rewind() and returns a zero value.
  */
-inline int Superimposed_ld::set (obj_no_t ldno)
+inline int Superimposed_ld::set(obj_no_t ldno)
 {
-  if (! is_linedef (ldno))		// Paranoia
-    return 1;
+    if (!is_linedef(ldno))	// Paranoia
+	return 1;
 
-  refldno = ldno;
-  rewind ();
-  return 0;
+    refldno = ldno;
+    rewind();
+    return 0;
 }
 
 
@@ -87,49 +87,49 @@
  *	Linedefs that have invalid start/end vertices are silently
  *	skipped.
  */
-inline obj_no_t Superimposed_ld::get ()
+inline obj_no_t Superimposed_ld::get()
 {
-  if (refldno == -1)
-    return -1;
+    if (refldno == -1)
+	return -1;
 
-  /* These variables are there to speed things up a bit by avoiding
-     repetitive table lookups. Everything is re-computed each time as
-     LineDefs could very well be realloc'd while we were out. */
+    /* These variables are there to speed things up a bit by avoiding
+       repetitive table lookups. Everything is re-computed each time as
+       LineDefs could very well be realloc'd while we were out. */
 
-  if (! is_linedef (refldno))
-    return -1;
-  const struct LineDef *const pmax = LineDefs + NumLineDefs;
-  const struct LineDef *const pref = LineDefs + refldno;
+    if (!is_linedef(refldno))
+	return -1;
+    const struct LineDef *const pmax = LineDefs + NumLineDefs;
+    const struct LineDef *const pref = LineDefs + refldno;
 
-  const wad_vn_t refv0 = pref->start;
-  const wad_vn_t refv1 = pref->end;
-  if (! is_vertex (refv0) || ! is_vertex (refv1))		// Paranoia
-    return -1;
+    const wad_vn_t refv0 = pref->start;
+    const wad_vn_t refv1 = pref->end;
+    if (!is_vertex(refv0) || !is_vertex(refv1))	// Paranoia
+	return -1;
 
-  const wad_coord_t refx0 = Vertices[refv0].x;
-  const wad_coord_t refy0 = Vertices[refv0].y;
-  const wad_coord_t refx1 = Vertices[refv1].x;
-  const wad_coord_t refy1 = Vertices[refv1].y;
+    const wad_coord_t refx0 = Vertices[refv0].x;
+    const wad_coord_t refy0 = Vertices[refv0].y;
+    const wad_coord_t refx1 = Vertices[refv1].x;
+    const wad_coord_t refy1 = Vertices[refv1].y;
 
-  for (const struct LineDef *p = LineDefs + ldno; ldno < NumLineDefs;
-      p++, ldno++)
-  {
-    if (! is_vertex (p->start) || ! is_vertex (p->end))		// Paranoia
-      continue;
-    obj_no_t x0 = Vertices[p->start].x;
-    obj_no_t y0 = Vertices[p->start].y;
-    obj_no_t x1 = Vertices[p->end].x;
-    obj_no_t y1 = Vertices[p->end].y;
-    if ( x0 == refx0 && y0 == refy0 && x1 == refx1 && y1 == refy1
-      || x0 == refx1 && y0 == refy1 && x1 == refx0 && y1 == refy0)
+    for (const struct LineDef * p = LineDefs + ldno; ldno < NumLineDefs;
+	 p++, ldno++)
     {
-      if (ldno == refldno)
-	continue;
-      return ldno++;
+	if (!is_vertex(p->start) || !is_vertex(p->end))	// Paranoia
+	    continue;
+	obj_no_t x0 = Vertices[p->start].x;
+	obj_no_t y0 = Vertices[p->start].y;
+	obj_no_t x1 = Vertices[p->end].x;
+	obj_no_t y1 = Vertices[p->end].y;
+	if (x0 == refx0 && y0 == refy0 && x1 == refx1 && y1 == refy1
+	    || x0 == refx1 && y0 == refy1 && x1 == refx0 && y1 == refy0)
+	{
+	    if (ldno == refldno)
+		continue;
+	    return ldno++;
+	}
     }
-  }
 
-  return -1;
+    return -1;
 }
 
 
@@ -139,10 +139,10 @@
  *	After calling this method, the next call to get() will start
  *	from the first linedef.
  */
-inline void Superimposed_ld::rewind ()
+inline void Superimposed_ld::rewind()
 {
-  ldno = 0;
+    ldno = 0;
 }
 
 
-#endif  /* DO NOT ADD ANYTHING AFTER THIS LINE */
+#endif /* DO NOT ADD ANYTHING AFTER THIS LINE */
--- a/src/l_unlink.cc	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/l_unlink.cc	Sat Sep 24 14:16:04 2011 +0300
@@ -48,63 +48,59 @@
  *
  *	This function is intended to "unlink" duplicated linedefs.
  */
-void unlink_sidedef (SelPtr linedefs, int side1, int side2)
+void unlink_sidedef(SelPtr linedefs, int side1, int side2)
 {
 // Array of NumSideDefs bits that tell whether the
 // sidedef is used by the linedefs in <linedefs>.
-bitvec_c sd_used_in (NumSideDefs);
+    bitvec_c sd_used_in(NumSideDefs);
 
 // Array of NumSideDefs bits that tell whether the
 // sidedef is used by the linedefs _not_ in <linedefs>.
-bitvec_c sd_used_out (NumSideDefs);
+    bitvec_c sd_used_out(NumSideDefs);
 
-SelPtr cur;
-int n;
+    SelPtr cur;
+    int n;
 
 // Put in sd_used_in a list of all sidedefs
 // that are used by linedefs in <linedefs>.
 // and in sd_used_out a list of all sidedefs
 // that are used by linedefs not in <linedefs>
 
-for (n = 0; n < NumLineDefs; n++)
-   {
-   if (IsSelected (linedefs, n))
-      {
-      if (side1 && is_sidedef (LineDefs[n].sidedef1))
-         sd_used_in.set (LineDefs[n].sidedef1);
-      if (side2 && is_sidedef (LineDefs[n].sidedef2))
-         sd_used_in.set (LineDefs[n].sidedef2);
-      }
-   else
-      {
-      if (is_sidedef (LineDefs[n].sidedef1))
-	 sd_used_out.set (LineDefs[n].sidedef1);
-      if (is_sidedef (LineDefs[n].sidedef2))
-	 sd_used_out.set (LineDefs[n].sidedef2);
-      }
-   }
+    for (n = 0; n < NumLineDefs; n++)
+    {
+	if (IsSelected(linedefs, n))
+	{
+	    if (side1 && is_sidedef(LineDefs[n].sidedef1))
+		sd_used_in.set(LineDefs[n].sidedef1);
+	    if (side2 && is_sidedef(LineDefs[n].sidedef2))
+		sd_used_in.set(LineDefs[n].sidedef2);
+	}
+	else
+	{
+	    if (is_sidedef(LineDefs[n].sidedef1))
+		sd_used_out.set(LineDefs[n].sidedef1);
+	    if (is_sidedef(LineDefs[n].sidedef2))
+		sd_used_out.set(LineDefs[n].sidedef2);
+	}
+    }
 
 // For all sidedefs that are used both by a linedef
 // in <linedefs> and a linedef _not_ in <linedefs>,
 // duplicate the sidedef and make all the linedefs
 // in <linedefs> use the copy instead.
 
-for (n = 0; n < NumSideDefs; n++)
-   {
-   if (sd_used_in.get (n) && sd_used_out.get (n))
-      {
-      InsertObject (OBJ_SIDEDEFS, n, 0, 0);
-      for (cur = linedefs; cur; cur = cur->next)
-         {
-         if (side1 && LineDefs[cur->objnum].sidedef1 == n)
-            LineDefs[cur->objnum].sidedef1 = NumSideDefs - 1;
-         if (side2 && LineDefs[cur->objnum].sidedef2 == n)
-            LineDefs[cur->objnum].sidedef2 = NumSideDefs - 1;
-         }
-      }
-   }
+    for (n = 0; n < NumSideDefs; n++)
+    {
+	if (sd_used_in.get(n) && sd_used_out.get(n))
+	{
+	    InsertObject(OBJ_SIDEDEFS, n, 0, 0);
+	    for (cur = linedefs; cur; cur = cur->next)
+	    {
+		if (side1 && LineDefs[cur->objnum].sidedef1 == n)
+		    LineDefs[cur->objnum].sidedef1 = NumSideDefs - 1;
+		if (side2 && LineDefs[cur->objnum].sidedef2 == n)
+		    LineDefs[cur->objnum].sidedef2 = NumSideDefs - 1;
+	    }
+	}
+    }
 }
-
-
-
-
--- a/src/l_vertices.cc	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/l_vertices.cc	Sat Sep 24 14:16:04 2011 +0300
@@ -38,19 +38,19 @@
  *	Return a bit vector of all vertices used by the linedefs.
  *	It's up to the caller to delete the bit vector after use.
  */
-bitvec_c *bv_vertices_of_linedefs (bitvec_c *linedefs)
+bitvec_c *bv_vertices_of_linedefs(bitvec_c * linedefs)
 {
-bitvec_c *vertices;
-int n;
+    bitvec_c *vertices;
+    int n;
 
-vertices = new bitvec_c (NumVertices);
-for (n = 0; n < NumLineDefs; n++)
-   if (linedefs->get (n))
-      {
-      vertices->set (LineDefs[n].start);
-      vertices->set (LineDefs[n].end);
-      }
-return vertices;
+    vertices = new bitvec_c(NumVertices);
+    for (n = 0; n < NumLineDefs; n++)
+	if (linedefs->get(n))
+	{
+	    vertices->set(LineDefs[n].start);
+	    vertices->set(LineDefs[n].end);
+	}
+    return vertices;
 }
 
 
@@ -59,18 +59,18 @@
  *	Return a bit vector of all vertices used by the linedefs.
  *	It's up to the caller to delete the bit vector after use.
  */
-bitvec_c *bv_vertices_of_linedefs (SelPtr list)
+bitvec_c *bv_vertices_of_linedefs(SelPtr list)
 {
-bitvec_c *vertices;
-SelPtr cur;
+    bitvec_c *vertices;
+    SelPtr cur;
 
-vertices = new bitvec_c (NumVertices);
-for (cur = list; cur; cur = cur->next)
-   {
-   vertices->set (LineDefs[cur->objnum].start);
-   vertices->set (LineDefs[cur->objnum].end);
-   }
-return vertices;
+    vertices = new bitvec_c(NumVertices);
+    for (cur = list; cur; cur = cur->next)
+    {
+	vertices->set(LineDefs[cur->objnum].start);
+	vertices->set(LineDefs[cur->objnum].end);
+    }
+    return vertices;
 }
 
 
@@ -79,20 +79,18 @@
  *	Return a list of all vertices used by the linedefs
  *	It's up to the caller to delete the list after use.
  */
-SelPtr list_vertices_of_linedefs (SelPtr list)
+SelPtr list_vertices_of_linedefs(SelPtr list)
 {
-bitvec_c *vertices_bitvec;
-SelPtr vertices_list = 0;
-size_t n;
+    bitvec_c *vertices_bitvec;
+    SelPtr vertices_list = 0;
+    size_t n;
 
-vertices_bitvec = bv_vertices_of_linedefs (list);
-for (n = 0; n < vertices_bitvec->nelements (); n++)
-   {
-   if (vertices_bitvec->get (n))
-      SelectObject (&vertices_list, n);
-   }
-delete vertices_bitvec;
-return vertices_list;
+    vertices_bitvec = bv_vertices_of_linedefs(list);
+    for (n = 0; n < vertices_bitvec->nelements(); n++)
+    {
+	if (vertices_bitvec->get(n))
+	    SelectObject(&vertices_list, n);
+    }
+    delete vertices_bitvec;
+    return vertices_list;
 }
-
-
--- a/src/l_vertices.h	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/l_vertices.h	Sat Sep 24 14:16:04 2011 +0300
@@ -8,7 +8,6 @@
 #include "selectn.h"
 
 
-bitvec_c *bv_vertices_of_linedefs (bitvec_c *linedefs);
-bitvec_c *bv_vertices_of_linedefs (SelPtr list);
-SelPtr list_vertices_of_linedefs (SelPtr list);
-
+bitvec_c *bv_vertices_of_linedefs(bitvec_c * linedefs);
+bitvec_c *bv_vertices_of_linedefs(SelPtr list);
+SelPtr list_vertices_of_linedefs(SelPtr list);
--- a/src/levels.cc	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/levels.cc	Sat Sep 24 14:16:04 2011 +0300
@@ -90,25 +90,25 @@
 				   of a "c" command, with or without
 				   argument, an empty string. */
 
-y_file_name_t Level_file_name_saved;  /* The name of the file in
-				   which the level was last saved. If
-				   the Level has never been saved yet,
-				   an empty string. */
+y_file_name_t Level_file_name_saved;	/* The name of the file in
+					   which the level was last saved. If
+					   the Level has never been saved yet,
+					   an empty string. */
 
-void EmptyLevelData (const char *levelname)
+void EmptyLevelData(const char *levelname)
 {
-Things = 0;
-NumThings = 0;
-things_angles++;
-things_types++;
-LineDefs = 0;
-NumLineDefs = 0;
-SideDefs = 0;
-NumSideDefs = 0;
-Sectors = 0;
-NumSectors = 0;
-Vertices = 0;
-NumVertices = 0;
+    Things = 0;
+    NumThings = 0;
+    things_angles++;
+    things_types++;
+    LineDefs = 0;
+    NumLineDefs = 0;
+    SideDefs = 0;
+    NumSideDefs = 0;
+    Sectors = 0;
+    NumSectors = 0;
+    Vertices = 0;
+    NumVertices = 0;
 }
 
 
@@ -119,23 +119,22 @@
 static char *tex_list = 0;
 static size_t ntex = 0;
 static char tex_name[WAD_TEX_NAME + 1];
-inline const char *texno_texname (i16 texno)
+inline const char *texno_texname(i16 texno)
 {
-if (texno < 0)
-   return "-";
-else
-   if (yg_texture_format == YGTF_NAMELESS)
-      {
-      sprintf (tex_name, "TEX%04u", (unsigned) texno);
-      return tex_name;
-      }
-   else
-      {
-      if (texno < (i16) ntex)
-	 return tex_list + WAD_TEX_NAME * texno;
-      else
-	 return "unknown";
-      }
+    if (texno < 0)
+	return "-";
+    else if (yg_texture_format == YGTF_NAMELESS)
+    {
+	sprintf(tex_name, "TEX%04u", (unsigned) texno);
+	return tex_name;
+    }
+    else
+    {
+	if (texno < (i16) ntex)
+	    return tex_list + WAD_TEX_NAME * texno;
+	else
+	    return "unknown";
+    }
 }
 
 
@@ -143,457 +142,460 @@
    read in the level data
 */
 
-int ReadLevelData (const char *levelname) /* SWAP! */
+int ReadLevelData(const char *levelname)	/* SWAP! */
 {
-int rc = 0;
-MDirPtr dir;
-int OldNumVertices;
+    int rc = 0;
+    MDirPtr dir;
+    int OldNumVertices;
 
 /* Find the various level information from the master directory */
-DisplayMessage (-1, -1, "Reading data for level %s...", levelname);
-Level = FindMasterDir (MasterDir, levelname);
-if (!Level)
-   fatal_error ("level data not found");
+    DisplayMessage(-1, -1, "Reading data for level %s...", levelname);
+    Level = FindMasterDir(MasterDir, levelname);
+    if (!Level)
+	fatal_error("level data not found");
 
 /* Get the number of vertices */
-i32 v_offset = 42;
-i32 v_length = 42;
-{
-const char *lump_name = "BUG";
-if (yg_level_format == YGLF_ALPHA)  // Doom alpha
-   lump_name = "POINTS";
-else
-   lump_name = "VERTEXES";
-dir = FindMasterDir (Level, lump_name);
-if (dir == 0)
-   OldNumVertices = 0;
-else
-   {
-   v_offset = dir->dir.start;
-   v_length = dir->dir.size;
-   if (yg_level_format == YGLF_ALPHA)  // Doom alpha: skip leading count
-      {
-      v_offset += 4;
-      v_length -= 4;
-      }
-   OldNumVertices = (int) (v_length / WAD_VERTEX_BYTES);
-   if ((i32) (OldNumVertices * WAD_VERTEX_BYTES) != v_length)
-      warn ("the %s lump has a weird size."
-        " The wad might be corrupt.\n", lump_name);
-   }
-}
+    i32 v_offset = 42;
+    i32 v_length = 42;
+    {
+	const char *lump_name = "BUG";
+	if (yg_level_format == YGLF_ALPHA)	// Doom alpha
+	    lump_name = "POINTS";
+	else
+	    lump_name = "VERTEXES";
+	dir = FindMasterDir(Level, lump_name);
+	if (dir == 0)
+	    OldNumVertices = 0;
+	else
+	{
+	    v_offset = dir->dir.start;
+	    v_length = dir->dir.size;
+	    if (yg_level_format == YGLF_ALPHA)	// Doom alpha: skip leading count
+	    {
+		v_offset += 4;
+		v_length -= 4;
+	    }
+	    OldNumVertices = (int) (v_length / WAD_VERTEX_BYTES);
+	    if ((i32) (OldNumVertices * WAD_VERTEX_BYTES) != v_length)
+		warn("the %s lump has a weird size."
+		     " The wad might be corrupt.\n", lump_name);
+	}
+    }
 
 // Read THINGS
-{
-const char *lump_name = "THINGS";
-verbmsg ("Reading %s things", levelname);
-i32 offset = 42;
-i32 length;
-dir = FindMasterDir (Level, lump_name);
-if (dir == 0)
-   NumThings = 0;
-else
-   {
-   offset = dir->dir.start;
-   length = dir->dir.size;
-   if (MainWad == Iwad4)  // Hexen mode
-      {
-      NumThings = (int) (length / WAD_HEXEN_THING_BYTES);
-      if ((i32) (NumThings * WAD_HEXEN_THING_BYTES) != length)
-         warn ("the %s lump has a weird size."
-            " The wad might be corrupt.\n", lump_name);
-      }
-   else                    // Doom/Heretic/Strife mode
-      {
-      if (yg_level_format == YGLF_ALPHA)  // Doom alpha: skip leading count
-	 {
-	 offset += 4;
-	 length -= 4;
-	 }
-      size_t thing_size = yg_level_format == YGLF_ALPHA ? 12 : WAD_THING_BYTES;
-      NumThings = (int) (length / thing_size);
-      if ((i32) (NumThings * thing_size) != length)
-         warn ("the %s lump has a weird size."
-            " The wad might be corrupt.\n", lump_name);
-      }
-   }
-things_angles++;
-things_types++;
-if (NumThings > 0)
-   {
-   Things = (TPtr) GetMemory ((unsigned long) NumThings
-      * sizeof (struct Thing));
-   const Wad_file *wf = dir->wadfile;
-   wf->seek (offset);
-   if (wf->error ())
-      {
-      err ("%s: seek error", lump_name);
-      rc = 1;
-      goto byebye;
-      }
-   if (MainWad == Iwad4)		// Hexen mode
-      for (long n = 0; n < NumThings; n++)
-	 {
-         u8 dummy2[6];
-	 wf->read_i16   ();					// Tid
-	 wf->read_i16   (&Things[n].xpos );
-	 wf->read_i16   (&Things[n].ypos );
-	 wf->read_i16   ();					// Height
-	 wf->read_i16   (&Things[n].angle);
-	 wf->read_i16   (&Things[n].type );
-	 wf->read_i16   (&Things[n].when );
-         wf->read_bytes (dummy2, sizeof dummy2);
-	 if (wf->error ())
+    {
+	const char *lump_name = "THINGS";
+	verbmsg("Reading %s things", levelname);
+	i32 offset = 42;
+	i32 length;
+	dir = FindMasterDir(Level, lump_name);
+	if (dir == 0)
+	    NumThings = 0;
+	else
+	{
+	    offset = dir->dir.start;
+	    length = dir->dir.size;
+	    if (MainWad == Iwad4)	// Hexen mode
+	    {
+		NumThings = (int) (length / WAD_HEXEN_THING_BYTES);
+		if ((i32) (NumThings * WAD_HEXEN_THING_BYTES) != length)
+		    warn("the %s lump has a weird size."
+			 " The wad might be corrupt.\n", lump_name);
+	    }
+	    else		// Doom/Heretic/Strife mode
 	    {
-	    err ("%s: error reading thing #%ld", lump_name, n);
-	    rc = 1;
-	    goto byebye;
+		if (yg_level_format == YGLF_ALPHA)	// Doom alpha: skip leading count
+		{
+		    offset += 4;
+		    length -= 4;
+		}
+		size_t thing_size =
+		    yg_level_format == YGLF_ALPHA ? 12 : WAD_THING_BYTES;
+		NumThings = (int) (length / thing_size);
+		if ((i32) (NumThings * thing_size) != length)
+		    warn("the %s lump has a weird size."
+			 " The wad might be corrupt.\n", lump_name);
+	    }
+	}
+	things_angles++;
+	things_types++;
+	if (NumThings > 0)
+	{
+	    Things = (TPtr) GetMemory((unsigned long) NumThings
+				      * sizeof(struct Thing));
+	    const Wad_file *wf = dir->wadfile;
+	    wf->seek(offset);
+	    if (wf->error())
+	    {
+		err("%s: seek error", lump_name);
+		rc = 1;
+		goto byebye;
 	    }
-	 }
-   else					// Doom/Heretic/Strife mode
-      for (long n = 0; n < NumThings; n++)
-	 {
-	 wf->read_i16 (&Things[n].xpos );
-	 wf->read_i16 (&Things[n].ypos );
-	 wf->read_i16 (&Things[n].angle);
-	 wf->read_i16 (&Things[n].type );
-	 if (yg_level_format == YGLF_ALPHA)
-	    wf->read_i16 ();		// Alpha. Don't know what it's for.
-	 wf->read_i16 (&Things[n].when );
-	 if (wf->error ())
-	    {
-	    err ("%s: error reading thing #%ld", lump_name, n);
-	    rc = 1;
-	    goto byebye;
-	    }
-	 }
-   }
-}
+	    if (MainWad == Iwad4)	// Hexen mode
+		for (long n = 0; n < NumThings; n++)
+		{
+		    u8 dummy2[6];
+		    wf->read_i16();	// Tid
+		    wf->read_i16(&Things[n].xpos);
+		    wf->read_i16(&Things[n].ypos);
+		    wf->read_i16();	// Height
+		    wf->read_i16(&Things[n].angle);
+		    wf->read_i16(&Things[n].type);
+		    wf->read_i16(&Things[n].when);
+		    wf->read_bytes(dummy2, sizeof dummy2);
+		    if (wf->error())
+		    {
+			err("%s: error reading thing #%ld", lump_name, n);
+			rc = 1;
+			goto byebye;
+		    }
+		}
+	    else		// Doom/Heretic/Strife mode
+		for (long n = 0; n < NumThings; n++)
+		{
+		    wf->read_i16(&Things[n].xpos);
+		    wf->read_i16(&Things[n].ypos);
+		    wf->read_i16(&Things[n].angle);
+		    wf->read_i16(&Things[n].type);
+		    if (yg_level_format == YGLF_ALPHA)
+			wf->read_i16();	// Alpha. Don't know what it's for.
+		    wf->read_i16(&Things[n].when);
+		    if (wf->error())
+		    {
+			err("%s: error reading thing #%ld", lump_name, n);
+			rc = 1;
+			goto byebye;
+		    }
+		}
+	}
+    }
 
 // Read LINEDEFS
-if (yg_level_format != YGLF_ALPHA)
-   {
-   const char *lump_name = "LINEDEFS";
-   verbmsg (" linedefs");
-   dir = FindMasterDir (Level, lump_name);
-   if (dir == 0)
-      NumLineDefs = 0;
-   else
-      {
-      if (MainWad == Iwad4)  // Hexen mode
-	 {
-	 NumLineDefs = (int) (dir->dir.size / WAD_HEXEN_LINEDEF_BYTES);
-	 if ((i32) (NumLineDefs * WAD_HEXEN_LINEDEF_BYTES) != dir->dir.size)
-	    warn ("the %s lump has a weird size."
-	       " The wad might be corrupt.\n", lump_name);
-	 }
-      else                   // Doom/Heretic/Strife mode
-	 {
-	 NumLineDefs = (int) (dir->dir.size / WAD_LINEDEF_BYTES);
-	 if ((i32) (NumLineDefs * WAD_LINEDEF_BYTES) != dir->dir.size)
-	    warn ("the %s lump has a weird size."
-	       " The wad might be corrupt.\n", lump_name);
-	 }
-      }
-   if (NumLineDefs > 0)
-      {
-      LineDefs = (LDPtr) GetMemory ((unsigned long) NumLineDefs
-	 * sizeof (struct LineDef));
-      const Wad_file *wf = dir->wadfile;
-      wf->seek (dir->dir.start);
-      if (wf->error ())
-	 {
-	 err ("%s: seek error", lump_name);
-	 rc = 1;
-	 goto byebye;
-	 }
-      if (MainWad == Iwad4)  // Hexen mode
-	 for (long n = 0; n < NumLineDefs; n++)
+    if (yg_level_format != YGLF_ALPHA)
+    {
+	const char *lump_name = "LINEDEFS";
+	verbmsg(" linedefs");
+	dir = FindMasterDir(Level, lump_name);
+	if (dir == 0)
+	    NumLineDefs = 0;
+	else
+	{
+	    if (MainWad == Iwad4)	// Hexen mode
+	    {
+		NumLineDefs = (int) (dir->dir.size / WAD_HEXEN_LINEDEF_BYTES);
+		if ((i32) (NumLineDefs * WAD_HEXEN_LINEDEF_BYTES) !=
+		    dir->dir.size)
+		    warn("the %s lump has a weird size."
+			 " The wad might be corrupt.\n", lump_name);
+	    }
+	    else		// Doom/Heretic/Strife mode
+	    {
+		NumLineDefs = (int) (dir->dir.size / WAD_LINEDEF_BYTES);
+		if ((i32) (NumLineDefs * WAD_LINEDEF_BYTES) != dir->dir.size)
+		    warn("the %s lump has a weird size."
+			 " The wad might be corrupt.\n", lump_name);
+	    }
+	}
+	if (NumLineDefs > 0)
+	{
+	    LineDefs = (LDPtr) GetMemory((unsigned long) NumLineDefs
+					 * sizeof(struct LineDef));
+	    const Wad_file *wf = dir->wadfile;
+	    wf->seek(dir->dir.start);
+	    if (wf->error())
 	    {
-	    u8 dummy[6];
-	    wf->read_i16   (&LineDefs[n].start);
-	    wf->read_i16   (&LineDefs[n].end);
-	    wf->read_i16   (&LineDefs[n].flags);
-	    wf->read_bytes (dummy, sizeof dummy);
-	    wf->read_i16   (&LineDefs[n].sidedef1);
-	    wf->read_i16   (&LineDefs[n].sidedef2);
-	    LineDefs[n].type = dummy[0];
-	    LineDefs[n].tag  = dummy[1];  // arg1 often contains a tag
-	    if (wf->error ())
-	       {
-	       err ("%s: error reading linedef #%ld", lump_name, n);
-	       rc = 1;
-	       goto byebye;
-	       }
+		err("%s: seek error", lump_name);
+		rc = 1;
+		goto byebye;
 	    }
-      else                   // Doom/Heretic/Strife mode
-	 for (long n = 0; n < NumLineDefs; n++)
-	    {
-	    wf->read_i16 (&LineDefs[n].start);
-	    wf->read_i16 (&LineDefs[n].end);
-	    wf->read_i16 (&LineDefs[n].flags);
-	    wf->read_i16 (&LineDefs[n].type);
-	    wf->read_i16 (&LineDefs[n].tag);
-	    wf->read_i16 (&LineDefs[n].sidedef1);
-	    wf->read_i16 (&LineDefs[n].sidedef2);
-	    if (wf->error ())
-	       {
-	       err ("%s: error reading linedef #%ld", lump_name, n);
-	       rc = 1;
-	       goto byebye;
-	       }
-	    }
-      }
-   }
+	    if (MainWad == Iwad4)	// Hexen mode
+		for (long n = 0; n < NumLineDefs; n++)
+		{
+		    u8 dummy[6];
+		    wf->read_i16(&LineDefs[n].start);
+		    wf->read_i16(&LineDefs[n].end);
+		    wf->read_i16(&LineDefs[n].flags);
+		    wf->read_bytes(dummy, sizeof dummy);
+		    wf->read_i16(&LineDefs[n].sidedef1);
+		    wf->read_i16(&LineDefs[n].sidedef2);
+		    LineDefs[n].type = dummy[0];
+		    LineDefs[n].tag = dummy[1];	// arg1 often contains a tag
+		    if (wf->error())
+		    {
+			err("%s: error reading linedef #%ld", lump_name, n);
+			rc = 1;
+			goto byebye;
+		    }
+		}
+	    else		// Doom/Heretic/Strife mode
+		for (long n = 0; n < NumLineDefs; n++)
+		{
+		    wf->read_i16(&LineDefs[n].start);
+		    wf->read_i16(&LineDefs[n].end);
+		    wf->read_i16(&LineDefs[n].flags);
+		    wf->read_i16(&LineDefs[n].type);
+		    wf->read_i16(&LineDefs[n].tag);
+		    wf->read_i16(&LineDefs[n].sidedef1);
+		    wf->read_i16(&LineDefs[n].sidedef2);
+		    if (wf->error())
+		    {
+			err("%s: error reading linedef #%ld", lump_name, n);
+			rc = 1;
+			goto byebye;
+		    }
+		}
+	}
+    }
 
 // Read SIDEDEFS
-{
-const char *lump_name = "SIDEDEFS";
-verbmsg (" sidedefs");
-dir = FindMasterDir (Level, lump_name);
-if (dir)
-   {
-   NumSideDefs = (int) (dir->dir.size / WAD_SIDEDEF_BYTES);
-   if ((i32) (NumSideDefs * WAD_SIDEDEF_BYTES) != dir->dir.size)
-      warn ("the SIDEDEFS lump has a weird size."
-         " The wad might be corrupt.\n");
-   }
-else
-   NumSideDefs = 0;
-if (NumSideDefs > 0)
-   {
-   SideDefs = (SDPtr) GetMemory ((unsigned long) NumSideDefs
-      * sizeof (struct SideDef));
-   const Wad_file *wf = dir->wadfile;
-   wf->seek (dir->dir.start);
-   if (wf->error ())
-      {
-      err ("%s: seek error", lump_name);
-      rc = 1;
-      goto byebye;
-      }
-   for (long n = 0; n < NumSideDefs; n++)
-      {
-      wf->read_i16   (&SideDefs[n].xoff);
-      wf->read_i16   (&SideDefs[n].yoff);
-      wf->read_bytes (&SideDefs[n].tex1, WAD_TEX_NAME);
-      wf->read_bytes (&SideDefs[n].tex2, WAD_TEX_NAME);
-      wf->read_bytes (&SideDefs[n].tex3, WAD_TEX_NAME);
-      wf->read_i16   (&SideDefs[n].sector);
-      if (wf->error ())
-	 {
-	 err ("%s: error reading sidedef #%ld", lump_name, n);
-	 rc = 1;
-	 goto byebye;
-	 }
-      }
-   }
-}
+    {
+	const char *lump_name = "SIDEDEFS";
+	verbmsg(" sidedefs");
+	dir = FindMasterDir(Level, lump_name);
+	if (dir)
+	{
+	    NumSideDefs = (int) (dir->dir.size / WAD_SIDEDEF_BYTES);
+	    if ((i32) (NumSideDefs * WAD_SIDEDEF_BYTES) != dir->dir.size)
+		warn("the SIDEDEFS lump has a weird size."
+		     " The wad might be corrupt.\n");
+	}
+	else
+	    NumSideDefs = 0;
+	if (NumSideDefs > 0)
+	{
+	    SideDefs = (SDPtr) GetMemory((unsigned long) NumSideDefs
+					 * sizeof(struct SideDef));
+	    const Wad_file *wf = dir->wadfile;
+	    wf->seek(dir->dir.start);
+	    if (wf->error())
+	    {
+		err("%s: seek error", lump_name);
+		rc = 1;
+		goto byebye;
+	    }
+	    for (long n = 0; n < NumSideDefs; n++)
+	    {
+		wf->read_i16(&SideDefs[n].xoff);
+		wf->read_i16(&SideDefs[n].yoff);
+		wf->read_bytes(&SideDefs[n].tex1, WAD_TEX_NAME);
+		wf->read_bytes(&SideDefs[n].tex2, WAD_TEX_NAME);
+		wf->read_bytes(&SideDefs[n].tex3, WAD_TEX_NAME);
+		wf->read_i16(&SideDefs[n].sector);
+		if (wf->error())
+		{
+		    err("%s: error reading sidedef #%ld", lump_name, n);
+		    rc = 1;
+		    goto byebye;
+		}
+	    }
+	}
+    }
 
 /* Sanity checkings on linedefs: the 1st and 2nd vertices
    must exist. The 1st and 2nd sidedefs must exist or be
    set to -1. */
-for (long n = 0; n < NumLineDefs; n++)
-   {
-   if (LineDefs[n].sidedef1 != -1
-      && outside (LineDefs[n].sidedef1, 0, NumSideDefs - 1))
-      {
-      err ("linedef %ld has bad 1st sidedef number %d, giving up",
-	 n, LineDefs[n].sidedef1);
-      rc = 1;
-      goto byebye;
-      }
-   if (LineDefs[n].sidedef2 != -1
-      && outside (LineDefs[n].sidedef2, 0, NumSideDefs - 1))
-      {
-      err ("linedef %ld has bad 2nd sidedef number %d, giving up",
-	 n, LineDefs[n].sidedef2);
-      rc = 1;
-      goto byebye;
-      }
-   if (outside (LineDefs[n].start, 0, OldNumVertices -1))
-      {
-      err ("linedef %ld has bad 1st vertex number %d, giving up",
-        n, LineDefs[n].start);
-      rc = 1;
-      goto byebye;
-      }
-   if (outside (LineDefs[n].end, 0, OldNumVertices - 1))
-      {
-      err ("linedef %ld has bad 2nd vertex number %d, giving up",
-        n, LineDefs[n].end);
-      rc = 1;
-      goto byebye;
-      }
-   }
+    for (long n = 0; n < NumLineDefs; n++)
+    {
+	if (LineDefs[n].sidedef1 != -1
+	    && outside(LineDefs[n].sidedef1, 0, NumSideDefs - 1))
+	{
+	    err("linedef %ld has bad 1st sidedef number %d, giving up",
+		n, LineDefs[n].sidedef1);
+	    rc = 1;
+	    goto byebye;
+	}
+	if (LineDefs[n].sidedef2 != -1
+	    && outside(LineDefs[n].sidedef2, 0, NumSideDefs - 1))
+	{
+	    err("linedef %ld has bad 2nd sidedef number %d, giving up",
+		n, LineDefs[n].sidedef2);
+	    rc = 1;
+	    goto byebye;
+	}
+	if (outside(LineDefs[n].start, 0, OldNumVertices - 1))
+	{
+	    err("linedef %ld has bad 1st vertex number %d, giving up",
+		n, LineDefs[n].start);
+	    rc = 1;
+	    goto byebye;
+	}
+	if (outside(LineDefs[n].end, 0, OldNumVertices - 1))
+	{
+	    err("linedef %ld has bad 2nd vertex number %d, giving up",
+		n, LineDefs[n].end);
+	    rc = 1;
+	    goto byebye;
+	}
+    }
 
 // Read LINES (Doom alpha only)
-if (yg_level_format == YGLF_ALPHA)
-   {
-   const char *lump_name = "LINES";
-   verbmsg (" lines");
-   dir = FindMasterDir (Level, lump_name);
-   if (dir)
-      {
-      if ((dir->dir.size - 4) % 36)
-	 warn ("the %s lump has a weird size. The wad might be corrupt.\n",
-	    lump_name);
-      const size_t nlines = dir->dir.size / 36;
-      NumLineDefs = nlines;
-      NumSideDefs = 2 * nlines;  // Worst case. We'll adjust later.
-      LineDefs = (LDPtr) GetMemory ((unsigned long) NumLineDefs
-	 * sizeof (struct LineDef));
-      SideDefs = (SDPtr) GetMemory ((unsigned long) NumSideDefs
-	 * sizeof (struct SideDef));
-      // Read TEXTURES
-      if (yg_texture_format != YGTF_NAMELESS)
-	 {
-	 const char *lump_name = "TEXTURES";
-	 bool success = false;
-	 ntex = 0;
-	 i32 *offset_table = 0;
-	 MDirPtr d = FindMasterDir (MasterDir, lump_name);
-	 if (! d)
-	    {
-	    warn ("%s: lump not found in directory\n", lump_name);
-	    goto textures_done;
-	    }
-	 {
-	 const Wad_file *wf = d->wadfile;
-	 wf->seek (d->dir.start);
-	 if (wf->error ())
+    if (yg_level_format == YGLF_ALPHA)
+    {
+	const char *lump_name = "LINES";
+	verbmsg(" lines");
+	dir = FindMasterDir(Level, lump_name);
+	if (dir)
+	{
+	    if ((dir->dir.size - 4) % 36)
+		warn("the %s lump has a weird size. The wad might be corrupt.\n", lump_name);
+	    const size_t nlines = dir->dir.size / 36;
+	    NumLineDefs = nlines;
+	    NumSideDefs = 2 * nlines;	// Worst case. We'll adjust later.
+	    LineDefs = (LDPtr) GetMemory((unsigned long) NumLineDefs
+					 * sizeof(struct LineDef));
+	    SideDefs = (SDPtr) GetMemory((unsigned long) NumSideDefs
+					 * sizeof(struct SideDef));
+	    // Read TEXTURES
+	    if (yg_texture_format != YGTF_NAMELESS)
 	    {
-	    warn ("%s: seek error\n", lump_name);
-	    goto textures_done;
-	    }
-	 i32 num;
-	 wf->read_i32 (&num);
-	 if (wf->error ())
-	    {
-	    warn ("%s: error reading texture count\n", lump_name);
-	    }
-	 if (num < 0 || num > 32767)
-	    {
-	    warn ("%s: bad texture count, giving up\n", lump_name);
-	    goto textures_done;
-	    }
-	 ntex = num;
-	 offset_table = new i32[ntex];
-	 for (size_t n = 0; n < ntex; n++)
-	    {
-	    wf->read_i32 (offset_table + n);
-	    if (wf->error ())
-	       {
-	       warn ("%s: error reading offsets table\n");
-	       goto textures_done;
-	       }
-	    }
-	 tex_list = (char *) GetMemory (ntex * WAD_TEX_NAME);
-	 for (size_t n = 0; n < ntex; n++)
-	    {
-	    const long offset = d->dir.start + offset_table[n];
-	    wf->seek (offset);
-	    if (wf->error ())
-	       {
-	       warn ("%s: seek error\n", lump_name);
-	       goto textures_done;
-	       }
-	    wf->read_bytes (tex_list + WAD_TEX_NAME * n, WAD_TEX_NAME);
-	    if (wf->error ())
-	       {
-	       warn ("%s: error reading texture names\n", lump_name);
-	       goto textures_done;
-	       }
-	    }
-	 success = true;
-	 }
+		const char *lump_name = "TEXTURES";
+		bool success = false;
+		ntex = 0;
+		i32 *offset_table = 0;
+		MDirPtr d = FindMasterDir(MasterDir, lump_name);
+		if (!d)
+		{
+		    warn("%s: lump not found in directory\n", lump_name);
+		    goto textures_done;
+		}
+		{
+		    const Wad_file *wf = d->wadfile;
+		    wf->seek(d->dir.start);
+		    if (wf->error())
+		    {
+			warn("%s: seek error\n", lump_name);
+			goto textures_done;
+		    }
+		    i32 num;
+		    wf->read_i32(&num);
+		    if (wf->error())
+		    {
+			warn("%s: error reading texture count\n", lump_name);
+		    }
+		    if (num < 0 || num > 32767)
+		    {
+			warn("%s: bad texture count, giving up\n", lump_name);
+			goto textures_done;
+		    }
+		    ntex = num;
+		    offset_table = new i32[ntex];
+		    for (size_t n = 0; n < ntex; n++)
+		    {
+			wf->read_i32(offset_table + n);
+			if (wf->error())
+			{
+			    warn("%s: error reading offsets table\n");
+			    goto textures_done;
+			}
+		    }
+		    tex_list = (char *) GetMemory(ntex * WAD_TEX_NAME);
+		    for (size_t n = 0; n < ntex; n++)
+		    {
+			const long offset = d->dir.start + offset_table[n];
+			wf->seek(offset);
+			if (wf->error())
+			{
+			    warn("%s: seek error\n", lump_name);
+			    goto textures_done;
+			}
+			wf->read_bytes(tex_list + WAD_TEX_NAME * n,
+				       WAD_TEX_NAME);
+			if (wf->error())
+			{
+			    warn("%s: error reading texture names\n",
+				 lump_name);
+			    goto textures_done;
+			}
+		    }
+		    success = true;
+		}
 
-	 textures_done:
-	 if (offset_table != 0)
-	    delete[] offset_table;
-	 if (! success)
-	    warn ("%s: errors found, won't be able to import texture names\n",
-	       lump_name);
-	 }
+	      textures_done:
+		if (offset_table != 0)
+		    delete[]offset_table;
+		if (!success)
+		    warn("%s: errors found, won't be able to import texture names\n", lump_name);
+	    }
 
-      const Wad_file *wf = dir->wadfile;
-      wf->seek (dir->dir.start + 4);
-      if (wf->error ())
-	 {
-	 err ("%s: seek error", lump_name);
-	 rc = 1;
-	 goto byebye;
-	 }
-      size_t s = 0;
-      for (size_t n = 0; n < nlines; n++)
-	 {
-	 LDPtr ld = LineDefs + n;
-	 ld->start   = wf->read_i16 ();
-	 ld->end     = wf->read_i16 ();
-	 ld->flags   = wf->read_i16 ();
-	               wf->read_i16 ();  // Unused ?
-	 ld->type    = wf->read_i16 ();
-	 ld->tag     = wf->read_i16 ();
-	               wf->read_i16 ();  // Unused ?
-	 i16 sector1 = wf->read_i16 ();
-	 i16 xofs1   = wf->read_i16 ();
-	 i16 tex1m   = wf->read_i16 ();
-	 i16 tex1u   = wf->read_i16 ();
-	 i16 tex1l   = wf->read_i16 ();
-	               wf->read_i16 ();  // Unused ?
-	 i16 sector2 = wf->read_i16 ();
-	 i16 xofs2   = wf->read_i16 ();
-	 i16 tex2m   = wf->read_i16 ();
-	 i16 tex2u   = wf->read_i16 ();
-	 i16 tex2l   = wf->read_i16 ();
-	 if (sector1 >= 0)			// Create first sidedef
+	    const Wad_file *wf = dir->wadfile;
+	    wf->seek(dir->dir.start + 4);
+	    if (wf->error())
+	    {
+		err("%s: seek error", lump_name);
+		rc = 1;
+		goto byebye;
+	    }
+	    size_t s = 0;
+	    for (size_t n = 0; n < nlines; n++)
 	    {
-	    ld->sidedef1 = s;
-	    SDPtr sd = SideDefs + s;
-	    sd->xoff = xofs1;
-	    sd->yoff = 0;
-	    memcpy (sd->tex1, texno_texname (tex1u), sizeof sd->tex1);
-	    memcpy (sd->tex2, texno_texname (tex1l), sizeof sd->tex2);
-	    memcpy (sd->tex3, texno_texname (tex1m), sizeof sd->tex3);
-	    sd->sector = sector1;
-	    s++;
+		LDPtr ld = LineDefs + n;
+		ld->start = wf->read_i16();
+		ld->end = wf->read_i16();
+		ld->flags = wf->read_i16();
+		wf->read_i16();	// Unused ?
+		ld->type = wf->read_i16();
+		ld->tag = wf->read_i16();
+		wf->read_i16();	// Unused ?
+		i16 sector1 = wf->read_i16();
+		i16 xofs1 = wf->read_i16();
+		i16 tex1m = wf->read_i16();
+		i16 tex1u = wf->read_i16();
+		i16 tex1l = wf->read_i16();
+		wf->read_i16();	// Unused ?
+		i16 sector2 = wf->read_i16();
+		i16 xofs2 = wf->read_i16();
+		i16 tex2m = wf->read_i16();
+		i16 tex2u = wf->read_i16();
+		i16 tex2l = wf->read_i16();
+		if (sector1 >= 0)	// Create first sidedef
+		{
+		    ld->sidedef1 = s;
+		    SDPtr sd = SideDefs + s;
+		    sd->xoff = xofs1;
+		    sd->yoff = 0;
+		    memcpy(sd->tex1, texno_texname(tex1u), sizeof sd->tex1);
+		    memcpy(sd->tex2, texno_texname(tex1l), sizeof sd->tex2);
+		    memcpy(sd->tex3, texno_texname(tex1m), sizeof sd->tex3);
+		    sd->sector = sector1;
+		    s++;
+		}
+		else		// No first sidedef !
+		    ld->sidedef1 = -1;
+		if (ld->flags & 0x04)	// Create second sidedef
+		{
+		    ld->sidedef2 = s;
+		    SDPtr sd = SideDefs + s;
+		    sd->xoff = xofs2;
+		    sd->yoff = 0;
+		    memcpy(sd->tex1, texno_texname(tex2u), sizeof sd->tex1);
+		    memcpy(sd->tex2, texno_texname(tex2l), sizeof sd->tex2);
+		    memcpy(sd->tex3, texno_texname(tex2m), sizeof sd->tex3);
+		    sd->sector = sector2;
+		    s++;
+		}
+		else
+		    ld->sidedef2 = -1;
+		if (wf->error())
+		{
+		    err("%s: error reading line #%d", lump_name, int (n));
+		    rc = 1;
+		    goto byebye;
+		}
 	    }
-	 else  // No first sidedef !
-	    ld->sidedef1 = -1;
-	 if (ld->flags & 0x04)			// Create second sidedef
+	    // (size_t) to silence GCC warning
+	    if ((size_t) NumSideDefs > s)	// Almost always true.
 	    {
-	    ld->sidedef2 = s;
-	    SDPtr sd = SideDefs + s;
-	    sd->xoff = xofs2;
-	    sd->yoff = 0;
-	    memcpy (sd->tex1, texno_texname (tex2u), sizeof sd->tex1);
-	    memcpy (sd->tex2, texno_texname (tex2l), sizeof sd->tex2);
-	    memcpy (sd->tex3, texno_texname (tex2m), sizeof sd->tex3);
-	    sd->sector = sector2;
-	    s++;
+		NumSideDefs = s;
+		SideDefs = (SDPtr) ResizeMemory(SideDefs,
+						(unsigned long) NumSideDefs *
+						sizeof(struct SideDef));
 	    }
-	 else
-	    ld->sidedef2 = -1;
-	 if (wf->error ())
-	    {
-	    err ("%s: error reading line #%d", lump_name, int (n));
-	    rc = 1;
-	    goto byebye;
-	    }
-	 }
-      // (size_t) to silence GCC warning
-      if ((size_t) NumSideDefs > s)  // Almost always true.
-         {
-	 NumSideDefs = s;
-         SideDefs = (SDPtr) ResizeMemory (SideDefs,
-	     (unsigned long) NumSideDefs * sizeof (struct SideDef));
-         }
-      if (tex_list)
-         FreeMemory (tex_list);
-      tex_list = 0;
-      ntex = 0;
-      }
-   }
+	    if (tex_list)
+		FreeMemory(tex_list);
+	    tex_list = 0;
+	    ntex = 0;
+	}
+    }
 
 /* Read the vertices. If the wad has been run through a nodes
    builder, there is a bunch of vertices at the end that are not
@@ -609,325 +611,335 @@
    all seem to do that (1). What if some don't ? Well, we would
    end up with many unwanted vertices in the level data. Nothing
    that a good CheckCrossReferences() couldn't take care of. */
-{
-verbmsg (" vertices");
-int last_used_vertex = -1;
-for (long n = 0; n < NumLineDefs; n++)
-   {
-   last_used_vertex = y_max (last_used_vertex, LineDefs[n].start);
-   last_used_vertex = y_max (last_used_vertex, LineDefs[n].end);
-   }
-NumVertices = last_used_vertex + 1;
+    {
+	verbmsg(" vertices");
+	int last_used_vertex = -1;
+	for (long n = 0; n < NumLineDefs; n++)
+	{
+	    last_used_vertex = y_max(last_used_vertex, LineDefs[n].start);
+	    last_used_vertex = y_max(last_used_vertex, LineDefs[n].end);
+	}
+	NumVertices = last_used_vertex + 1;
 // This block is only here to warn me if (1) is false.
-{
-  bitvec_c vertex_used (OldNumVertices);
-  for (long n = 0; n < NumLineDefs; n++)
-     {
-     vertex_used.set (LineDefs[n].start);
-     vertex_used.set (LineDefs[n].end);
-     }
-  int unused = 0;
-  for (long n = 0; n <= last_used_vertex; n++)
-     {
-     if (! vertex_used.get (n))
-	unused++;
-     }
-  if (unused > 0)
-     {
-     warn ("this level has unused vertices in the middle.\n");
-     warn ("total %d, tail %d (%d%%), unused %d (",
-	OldNumVertices,
-	OldNumVertices - NumVertices,
-	NumVertices - unused
-	   ? 100 * (OldNumVertices - NumVertices) / (NumVertices - unused)
-	   : 0,
-	unused);
-     int first = 1;
-     for (int n = 0; n <= last_used_vertex; n++)
-        {
-	if (! vertex_used.get (n))
-	   {
-	   if (n == 0 || vertex_used.get (n - 1))
-	      {
-	      if (first)
-	         first = 0;
-	      else
-	         warn (", ");
-	      warn ("%d", n);
-	      }
-	   else if (n == last_used_vertex || vertex_used.get (n + 1))
-	      warn ("-%d", n);
-	   }
+	{
+	    bitvec_c vertex_used(OldNumVertices);
+	    for (long n = 0; n < NumLineDefs; n++)
+	    {
+		vertex_used.set(LineDefs[n].start);
+		vertex_used.set(LineDefs[n].end);
+	    }
+	    int unused = 0;
+	    for (long n = 0; n <= last_used_vertex; n++)
+	    {
+		if (!vertex_used.get(n))
+		    unused++;
+	    }
+	    if (unused > 0)
+	    {
+		warn("this level has unused vertices in the middle.\n");
+		warn("total %d, tail %d (%d%%), unused %d (",
+		     OldNumVertices,
+		     OldNumVertices - NumVertices,
+		     NumVertices - unused
+		     ? 100 * (OldNumVertices - NumVertices) / (NumVertices -
+							       unused) : 0,
+		     unused);
+		int first = 1;
+		for (int n = 0; n <= last_used_vertex; n++)
+		{
+		    if (!vertex_used.get(n))
+		    {
+			if (n == 0 || vertex_used.get(n - 1))
+			{
+			    if (first)
+				first = 0;
+			    else
+				warn(", ");
+			    warn("%d", n);
+			}
+			else if (n == last_used_vertex
+				 || vertex_used.get(n + 1))
+			    warn("-%d", n);
+		    }
+		}
+		warn(")\n");
+	    }
 	}
-     warn (")\n");
-     }
-}
 // Now load all the vertices except the unused ones at the end.
-if (NumVertices > 0)
-   {
-   const char *lump_name = "BUG";
-   Vertices = (VPtr) GetMemory ((unsigned long) NumVertices
-      * sizeof (struct Vertex));
-   if (yg_level_format == YGLF_ALPHA)  // Doom alpha
-      lump_name = "POINTS";
-   else
-      lump_name = "VERTEXES";
-   dir = FindMasterDir (Level, lump_name);
-   if (dir == 0)
-      goto vertexes_done;		// FIXME isn't that fatal ?
-   {
-   const Wad_file *wf = dir->wadfile;
-   wf->seek (v_offset);
-   if (wf->error ())
-      {
-      err ("%s: seek error", lump_name);
-      rc = 1;
-      goto byebye;
-      }
-   MapMaxX = -32767;
-   MapMaxY = -32767;
-   MapMinX = 32767;
-   MapMinY = 32767;
-   for (long n = 0; n < NumVertices; n++)
-      {
-      i16 val;
-      wf->read_i16 (&val);
-      if (val < MapMinX)
-	 MapMinX = val;
-      if (val > MapMaxX)
-	 MapMaxX = val;
-      Vertices[n].x = val;
-      wf->read_i16 (&val);
-      if (val < MapMinY)
-	 MapMinY = val;
-      if (val > MapMaxY)
-	 MapMaxY = val;
-      Vertices[n].y = val;
-      if (wf->error ())
-	 {
-	 err ("%s: error reading vertex #%ld", lump_name, n);
-	 rc = 1;
-	 goto byebye;
-	 }
-      }
-   }
-   vertexes_done:
-   ;
-   }
-}
+	if (NumVertices > 0)
+	{
+	    const char *lump_name = "BUG";
+	    Vertices = (VPtr) GetMemory((unsigned long) NumVertices
+					* sizeof(struct Vertex));
+	    if (yg_level_format == YGLF_ALPHA)	// Doom alpha
+		lump_name = "POINTS";
+	    else
+		lump_name = "VERTEXES";
+	    dir = FindMasterDir(Level, lump_name);
+	    if (dir == 0)
+		goto vertexes_done;	// FIXME isn't that fatal ?
+	    {
+		const Wad_file *wf = dir->wadfile;
+		wf->seek(v_offset);
+		if (wf->error())
+		{
+		    err("%s: seek error", lump_name);
+		    rc = 1;
+		    goto byebye;
+		}
+		MapMaxX = -32767;
+		MapMaxY = -32767;
+		MapMinX = 32767;
+		MapMinY = 32767;
+		for (long n = 0; n < NumVertices; n++)
+		{
+		    i16 val;
+		    wf->read_i16(&val);
+		    if (val < MapMinX)
+			MapMinX = val;
+		    if (val > MapMaxX)
+			MapMaxX = val;
+		    Vertices[n].x = val;
+		    wf->read_i16(&val);
+		    if (val < MapMinY)
+			MapMinY = val;
+		    if (val > MapMaxY)
+			MapMaxY = val;
+		    Vertices[n].y = val;
+		    if (wf->error())
+		    {
+			err("%s: error reading vertex #%ld", lump_name, n);
+			rc = 1;
+			goto byebye;
+		    }
+		}
+	    }
+	  vertexes_done:
+	    ;
+	}
+    }
 
 // Ignore SEGS, SSECTORS and NODES
 
 // Read SECTORS
-{
-const char *lump_name = "SECTORS";
-verbmsg (" sectors\n");
-dir = FindMasterDir (Level, lump_name);
-if (yg_level_format != YGLF_ALPHA)
-   {
-   if (dir)
-      {
-      NumSectors = (int) (dir->dir.size / WAD_SECTOR_BYTES);
-      if ((i32) (NumSectors * WAD_SECTOR_BYTES) != dir->dir.size)
-	 warn ("the %s lump has a weird size."
-	   " The wad might be corrupt.\n", lump_name);
-      }
-   else
-      NumSectors = 0;
-   if (NumSectors > 0)
-      {
-      Sectors = (SPtr) GetMemory ((unsigned long) NumSectors
-	 * sizeof (struct Sector));
-      const Wad_file *wf = dir->wadfile;
-      wf->seek (dir->dir.start);
-      if (wf->error ())
-	 {
-	 err ("%s: seek error", lump_name);
-	 rc = 1;
-	 goto byebye;
-	 }
-      for (long n = 0; n < NumSectors; n++)
-	 {
-	 wf->read_i16   (&Sectors[n].floorh);
-	 wf->read_i16   (&Sectors[n].ceilh);
-	 wf->read_bytes (&Sectors[n].floort, WAD_FLAT_NAME);
-	 wf->read_bytes (&Sectors[n].ceilt,  WAD_FLAT_NAME);
-	 wf->read_i16   (&Sectors[n].light);
-	 wf->read_i16   (&Sectors[n].special);
-	 wf->read_i16   (&Sectors[n].tag);
-	 if (wf->error ())
+    {
+	const char *lump_name = "SECTORS";
+	verbmsg(" sectors\n");
+	dir = FindMasterDir(Level, lump_name);
+	if (yg_level_format != YGLF_ALPHA)
+	{
+	    if (dir)
+	    {
+		NumSectors = (int) (dir->dir.size / WAD_SECTOR_BYTES);
+		if ((i32) (NumSectors * WAD_SECTOR_BYTES) != dir->dir.size)
+		    warn("the %s lump has a weird size."
+			 " The wad might be corrupt.\n", lump_name);
+	    }
+	    else
+		NumSectors = 0;
+	    if (NumSectors > 0)
 	    {
-	    err ("%s: error reading sector #%ld", lump_name, n);
-	    rc = 1;
-	    goto byebye;
+		Sectors = (SPtr) GetMemory((unsigned long) NumSectors
+					   * sizeof(struct Sector));
+		const Wad_file *wf = dir->wadfile;
+		wf->seek(dir->dir.start);
+		if (wf->error())
+		{
+		    err("%s: seek error", lump_name);
+		    rc = 1;
+		    goto byebye;
+		}
+		for (long n = 0; n < NumSectors; n++)
+		{
+		    wf->read_i16(&Sectors[n].floorh);
+		    wf->read_i16(&Sectors[n].ceilh);
+		    wf->read_bytes(&Sectors[n].floort, WAD_FLAT_NAME);
+		    wf->read_bytes(&Sectors[n].ceilt, WAD_FLAT_NAME);
+		    wf->read_i16(&Sectors[n].light);
+		    wf->read_i16(&Sectors[n].special);
+		    wf->read_i16(&Sectors[n].tag);
+		    if (wf->error())
+		    {
+			err("%s: error reading sector #%ld", lump_name, n);
+			rc = 1;
+			goto byebye;
+		    }
+		}
+	    }
+	}
+	else			// Doom alpha--a wholly different SECTORS format
+	{
+	    i32 *offset_table = 0;
+	    i32 nsectors = 0;
+	    i32 nflatnames = 0;
+	    char *flatnames = 0;
+	    if (dir == 0)
+	    {
+		warn("%s: lump not found in directory\n", lump_name);	// FIXME fatal ?
+		goto sectors_alpha_done;
 	    }
-	 }
-      }
-   }
-else  // Doom alpha--a wholly different SECTORS format
-   {
-   i32  *offset_table = 0;
-   i32   nsectors     = 0;
-   i32   nflatnames   = 0;
-   char *flatnames    = 0;
-   if (dir == 0)
-      {
-      warn ("%s: lump not found in directory\n", lump_name);  // FIXME fatal ?
-      goto sectors_alpha_done;
-      }
-   {
-   const Wad_file *wf = dir->wadfile;
-   wf->seek (dir->dir.start);
-   if (wf->error ())
-      {
-      err ("%s: seek error", lump_name);
-      rc = 1;
-      goto byebye;
-      }
-   wf->read_i32 (&nsectors);
-   if (wf->error ())
-      {
-      err ("%s: error reading sector count", lump_name);
-      rc = 1;
-      goto byebye;
-      }
-   if (nsectors < 0)
-      {
-      warn ("Negative sector count. Clamping to 0.\n");
-      nsectors = 0;
-      }
-   NumSectors = nsectors;
-   Sectors = (SPtr) GetMemory ((unsigned long) NumSectors
-      * sizeof (struct Sector));
-   offset_table = new i32[nsectors];
-   for (size_t n = 0; n < (size_t) nsectors; n++)
-      wf->read_i32 (offset_table + n);
-   if (wf->error ())
-      {
-      err ("%s: error reading offsets table", lump_name);
-      rc = 1;
-      goto sectors_alpha_done;
-      }
-   // Load FLATNAME
-   {
-      const char *lump_name = "FLATNAME";
-      bool success = false;
-      MDirPtr dir2 = FindMasterDir (Level, lump_name);
-      if (dir2 == 0)
-	 {
-	 warn ("%s: lump not found in directory\n", lump_name);
-	 goto flatname_done;		// FIXME warn ?
-	 }
-      {
-      const Wad_file *wf = dir2->wadfile;
-      wf->seek (dir2->dir.start);
-      if (wf->error ())
-	 {
-	 warn ("%s: seek error\n", lump_name);
-	 goto flatname_done;
-	 }
-      wf->read_i32 (&nflatnames);
-      if (wf->error ())
-	 {
-	 warn ("%s: error reading flat name count\n", lump_name);
-	 nflatnames = 0;
-	 goto flatname_done;
-	 }
-      if (nflatnames < 0 || nflatnames > 32767)
-	 {
-	 warn ("%s: bad flat name count, giving up\n", lump_name);
-	 nflatnames = 0;
-	 goto flatname_done;
-	 }
-      else
-	 {
-	 flatnames = new char[WAD_FLAT_NAME * nflatnames];
-	 wf->read_bytes (flatnames, WAD_FLAT_NAME * nflatnames);
-	 if (wf->error ())
 	    {
-	    warn ("%s: error reading flat names\n", lump_name);
-	    nflatnames = 0;
-	    goto flatname_done;
+		const Wad_file *wf = dir->wadfile;
+		wf->seek(dir->dir.start);
+		if (wf->error())
+		{
+		    err("%s: seek error", lump_name);
+		    rc = 1;
+		    goto byebye;
+		}
+		wf->read_i32(&nsectors);
+		if (wf->error())
+		{
+		    err("%s: error reading sector count", lump_name);
+		    rc = 1;
+		    goto byebye;
+		}
+		if (nsectors < 0)
+		{
+		    warn("Negative sector count. Clamping to 0.\n");
+		    nsectors = 0;
+		}
+		NumSectors = nsectors;
+		Sectors = (SPtr) GetMemory((unsigned long) NumSectors
+					   * sizeof(struct Sector));
+		offset_table = new i32[nsectors];
+		for (size_t n = 0; n < (size_t) nsectors; n++)
+		    wf->read_i32(offset_table + n);
+		if (wf->error())
+		{
+		    err("%s: error reading offsets table", lump_name);
+		    rc = 1;
+		    goto sectors_alpha_done;
+		}
+		// Load FLATNAME
+		{
+		    const char *lump_name = "FLATNAME";
+		    bool success = false;
+		    MDirPtr dir2 = FindMasterDir(Level, lump_name);
+		    if (dir2 == 0)
+		    {
+			warn("%s: lump not found in directory\n", lump_name);
+			goto flatname_done;	// FIXME warn ?
+		    }
+		    {
+			const Wad_file *wf = dir2->wadfile;
+			wf->seek(dir2->dir.start);
+			if (wf->error())
+			{
+			    warn("%s: seek error\n", lump_name);
+			    goto flatname_done;
+			}
+			wf->read_i32(&nflatnames);
+			if (wf->error())
+			{
+			    warn("%s: error reading flat name count\n",
+				 lump_name);
+			    nflatnames = 0;
+			    goto flatname_done;
+			}
+			if (nflatnames < 0 || nflatnames > 32767)
+			{
+			    warn("%s: bad flat name count, giving up\n",
+				 lump_name);
+			    nflatnames = 0;
+			    goto flatname_done;
+			}
+			else
+			{
+			    flatnames = new char[WAD_FLAT_NAME * nflatnames];
+			    wf->read_bytes(flatnames,
+					   WAD_FLAT_NAME * nflatnames);
+			    if (wf->error())
+			    {
+				warn("%s: error reading flat names\n",
+				     lump_name);
+				nflatnames = 0;
+				goto flatname_done;
+			    }
+			    success = true;
+			}
+		    }
+		  flatname_done:
+		    if (!success)
+			warn("%s: errors found, you'll have to do without flat names\n", lump_name);
+		}
+		for (size_t n = 0; n < (size_t) nsectors; n++)
+		{
+		    wf->seek(dir->dir.start + offset_table[n]);
+		    if (wf->error())
+		    {
+			err("%s: seek error", lump_name);
+			rc = 1;
+			goto sectors_alpha_done;
+		    }
+		    i16 index;
+		    wf->read_i16(&Sectors[n].floorh);
+		    wf->read_i16(&Sectors[n].ceilh);
+		    wf->read_i16(&index);
+		    if (nflatnames && flatnames && index >= 0
+			&& index < nflatnames)
+			memcpy(Sectors[n].floort,
+			       flatnames + WAD_FLAT_NAME * index,
+			       WAD_FLAT_NAME);
+		    else
+			strcpy(Sectors[n].floort, "unknown");
+		    wf->read_i16(&index);
+		    if (nflatnames && flatnames && index >= 0
+			&& index < nflatnames)
+			memcpy(Sectors[n].ceilt,
+			       flatnames + WAD_FLAT_NAME * index,
+			       WAD_FLAT_NAME);
+		    else
+			strcpy(Sectors[n].ceilt, "unknown");
+		    wf->read_i16(&Sectors[n].light);
+		    wf->read_i16(&Sectors[n].special);
+		    wf->read_i16(&Sectors[n].tag);
+		    // Don't know what the tail is for. Ignore it.
+		    if (wf->error())
+		    {
+			err("%s: error reading sector #%ld", lump_name,
+			    long (n));
+			rc = 1;
+			goto sectors_alpha_done;
+		    }
+		}
 	    }
-	 success = true;
-	 }
-      }
-      flatname_done:
-      if (! success)
-	 warn ("%s: errors found, you'll have to do without flat names\n",
-	       lump_name);
-   }
-   for (size_t n = 0; n < (size_t) nsectors; n++)
-      {
-      wf->seek (dir->dir.start + offset_table[n]);
-      if (wf->error ())
-	 {
-	 err ("%s: seek error", lump_name);
-	 rc = 1;
-	 goto sectors_alpha_done;
-	 }
-      i16 index;
-      wf->read_i16 (&Sectors[n].floorh);
-      wf->read_i16 (&Sectors[n].ceilh );
-      wf->read_i16 (&index);
-      if (nflatnames && flatnames && index >= 0 && index < nflatnames)
-	 memcpy (Sectors[n].floort, flatnames + WAD_FLAT_NAME * index,
-	     WAD_FLAT_NAME);
-      else
-	 strcpy (Sectors[n].floort, "unknown");
-      wf->read_i16 (&index);
-      if (nflatnames && flatnames && index >= 0 && index < nflatnames)
-	 memcpy (Sectors[n].ceilt, flatnames + WAD_FLAT_NAME * index,
-	     WAD_FLAT_NAME);
-      else
-	 strcpy (Sectors[n].ceilt, "unknown");
-      wf->read_i16 (&Sectors[n].light);
-      wf->read_i16 (&Sectors[n].special);
-      wf->read_i16 (&Sectors[n].tag);
-      // Don't know what the tail is for. Ignore it.
-      if (wf->error ())
-	 {
-	 err ("%s: error reading sector #%ld", lump_name, long (n));
-	 rc = 1;
-	 goto sectors_alpha_done;
-	 }
-      }
-   }
-   
-   sectors_alpha_done:
-   if (offset_table != 0)
-      delete[] offset_table;
-   if (flatnames != 0)
-      delete[] flatnames;
-   if (rc != 0)
-      goto byebye;
-   }
-}
+
+	  sectors_alpha_done:
+	    if (offset_table != 0)
+		delete[]offset_table;
+	    if (flatnames != 0)
+		delete[]flatnames;
+	    if (rc != 0)
+		goto byebye;
+	}
+    }
 
 /* Sanity checking on sidedefs: the sector must exist. I don't
    make this a fatal error, though, because it's not exceptional
    to find wads with unused sidedefs with a sector# of -1. Well
    known ones include dyst3 (MAP06, MAP07, MAP08), mm (MAP16),
    mm2 (MAP13, MAP28) and requiem (MAP03, MAP08, ...). */
-for (long n = 0; n < NumSideDefs; n++)
-   {
-   if (outside (SideDefs[n].sector, 0, NumSectors - 1))
-      warn ("sidedef %ld has bad sector number %d\n",
-	 n, SideDefs[n].sector);
-   }
+    for (long n = 0; n < NumSideDefs; n++)
+    {
+	if (outside(SideDefs[n].sector, 0, NumSectors - 1))
+	    warn("sidedef %ld has bad sector number %d\n",
+		 n, SideDefs[n].sector);
+    }
 
 // Ignore REJECT and BLOCKMAP
 
 // Silly statistics
-verbmsg ("  %d things, %d vertices, %d linedefs, %d sidedefs, %d sectors\n",
-   (int) NumThings, (int) NumVertices, (int) NumLineDefs,
-   (int) NumSideDefs, (int) NumSectors);
-verbmsg ("  Map: (%d,%d)-(%d,%d)\n", MapMinX, MapMinY, MapMaxX, MapMaxY);
+    verbmsg
+	("  %d things, %d vertices, %d linedefs, %d sidedefs, %d sectors\n",
+	 (int) NumThings, (int) NumVertices, (int) NumLineDefs,
+	 (int) NumSideDefs, (int) NumSectors);
+    verbmsg("  Map: (%d,%d)-(%d,%d)\n", MapMinX, MapMinY, MapMaxX, MapMaxY);
 
-byebye:
-if (rc != 0)
-   err ("%s: errors found, giving up", levelname);
-return rc;
+  byebye:
+    if (rc != 0)
+	err("%s: errors found, giving up", levelname);
+    return rc;
 }
 
 
@@ -936,39 +948,39 @@
    forget the level data
 */
 
-void ForgetLevelData () /* SWAP! */
+void ForgetLevelData()		/* SWAP! */
 {
 /* forget the things */
-NumThings = 0;
-if (Things != 0)
-   FreeMemory (Things);
-Things = 0;
-things_angles++;
-things_types++;
+    NumThings = 0;
+    if (Things != 0)
+	FreeMemory(Things);
+    Things = 0;
+    things_angles++;
+    things_types++;
 
 /* forget the vertices */
-NumVertices = 0;
-if (Vertices != 0)
-   FreeMemory (Vertices);
-Vertices = 0;
+    NumVertices = 0;
+    if (Vertices != 0)
+	FreeMemory(Vertices);
+    Vertices = 0;
 
 /* forget the linedefs */
-NumLineDefs = 0;
-if (LineDefs != 0)
-   FreeMemory (LineDefs);
-LineDefs = 0;
+    NumLineDefs = 0;
+    if (LineDefs != 0)
+	FreeMemory(LineDefs);
+    LineDefs = 0;
 
 /* forget the sidedefs */
-NumSideDefs = 0;
-if (SideDefs != 0)
-   FreeMemory (SideDefs);
-SideDefs = 0;
+    NumSideDefs = 0;
+    if (SideDefs != 0)
+	FreeMemory(SideDefs);
+    SideDefs = 0;
 
 /* forget the sectors */
-NumSectors = 0;
-if (Sectors != 0)
-   FreeMemory (Sectors);
-Sectors = 0;
+    NumSectors = 0;
+    if (Sectors != 0)
+	FreeMemory(Sectors);
+    Sectors = 0;
 }
 
 
@@ -997,265 +1009,265 @@
  *
  *	Returns 0 on success and non-zero on failure (see errno).
  */
-int SaveLevelData (const char *outfile, const char *level_name) /* SWAP! */
+int SaveLevelData(const char *outfile, const char *level_name)	/* SWAP! */
 {
-FILE   *file;
-MDirPtr dir;
-int     n;
-long	lump_offset[WAD_LL__];
-size_t	lump_size[WAD_LL__];
-wad_level_lump_no_t l;
+    FILE *file;
+    MDirPtr dir;
+    int n;
+    long lump_offset[WAD_LL__];
+    size_t lump_size[WAD_LL__];
+    wad_level_lump_no_t l;
 
-if (yg_level_format == YGLF_HEXEN || ! strcmp (Game, "hexen"))
-   {
-   Notify (-1, -1, "I refuse to save. Hexen mode is still",
-                   "too badly broken. You would lose data.");
-   return 1;
-   }
-if (! level_name || ! levelname2levelno (level_name))
-   {
-   nf_bug ("SaveLevelData: bad level_name \"%s\", using \"E1M1\" instead.",
-       level_name);
-   level_name = "E1M1";
-   }
-DisplayMessage (-1, -1, "Saving data to \"%s\"...", outfile);
-LogMessage (": Saving data to \"%s\"...\n", outfile);
-if ((file = fopen (outfile, "wb")) == NULL)
-   {
-   char buf1[81];
-   char buf2[81];
-   y_snprintf (buf1, sizeof buf1, "Can't open \"%.64s\"", outfile);
-   y_snprintf (buf2, sizeof buf1, "for writing (%.64s)",  strerror (errno));
-   Notify (-1, -1, buf1, buf2);
-   return 1;
-   }
+    if (yg_level_format == YGLF_HEXEN || !strcmp(Game, "hexen"))
+    {
+	Notify(-1, -1, "I refuse to save. Hexen mode is still",
+	       "too badly broken. You would lose data.");
+	return 1;
+    }
+    if (!level_name || !levelname2levelno(level_name))
+    {
+	nf_bug
+	    ("SaveLevelData: bad level_name \"%s\", using \"E1M1\" instead.",
+	     level_name);
+	level_name = "E1M1";
+    }
+    DisplayMessage(-1, -1, "Saving data to \"%s\"...", outfile);
+    LogMessage(": Saving data to \"%s\"...\n", outfile);
+    if ((file = fopen(outfile, "wb")) == NULL)
+    {
+	char buf1[81];
+	char buf2[81];
+	y_snprintf(buf1, sizeof buf1, "Can't open \"%.64s\"", outfile);
+	y_snprintf(buf2, sizeof buf1, "for writing (%.64s)", strerror(errno));
+	Notify(-1, -1, buf1, buf2);
+	return 1;
+    }
 
 /* Can we reuse the old nodes ? Not if this is a new level from
    scratch or if the structure of the level has changed. If the
    level comes from an alpha version of Doom, we can't either
    because that version of Doom didn't have SEGS, NODES, etc. */
-bool reuse_nodes = Level
-  && ! MadeMapChanges
-  && yg_level_format != YGLF_ALPHA;
+    bool reuse_nodes = Level
+	&& !MadeMapChanges && yg_level_format != YGLF_ALPHA;
 
 // Write the pwad header
-WriteBytes (file, "PWAD", 4);		// Pwad file
-file_write_i32 (file, WAD_LL__);	// Number of entries = 11
-file_write_i32 (file, 0);		// Fix this up later
-if (Level)
-   dir = Level->next;
-else
-   dir = 0;  // Useless except to trap accidental dereferences
+    WriteBytes(file, "PWAD", 4);	// Pwad file
+    file_write_i32(file, WAD_LL__);	// Number of entries = 11
+    file_write_i32(file, 0);	// Fix this up later
+    if (Level)
+	dir = Level->next;
+    else
+	dir = 0;		// Useless except to trap accidental dereferences
 
 // The label (EnMm or MAPnm)
-l = WAD_LL_LABEL;
-lump_offset[l] = ftell (file);	// By definition
-lump_size[l]   =  0;		// By definition
- 
+    l = WAD_LL_LABEL;
+    lump_offset[l] = ftell(file);	// By definition
+    lump_size[l] = 0;		// By definition
+
 // Write the THINGS lump
-l = WAD_LL_THINGS;
-lump_offset[l] = ftell (file);
-for (n = 0; n < NumThings; n++)
-   {
-   file_write_i16 (file, Things[n].xpos );
-   file_write_i16 (file, Things[n].ypos );
-   file_write_i16 (file, Things[n].angle);
-   file_write_i16 (file, Things[n].type );
-   file_write_i16 (file, Things[n].when );
-   }
-lump_size[l] = ftell (file) - lump_offset[l];
-if (Level)
-   dir = dir->next;
+    l = WAD_LL_THINGS;
+    lump_offset[l] = ftell(file);
+    for (n = 0; n < NumThings; n++)
+    {
+	file_write_i16(file, Things[n].xpos);
+	file_write_i16(file, Things[n].ypos);
+	file_write_i16(file, Things[n].angle);
+	file_write_i16(file, Things[n].type);
+	file_write_i16(file, Things[n].when);
+    }
+    lump_size[l] = ftell(file) - lump_offset[l];
+    if (Level)
+	dir = dir->next;
 
 // Write the LINEDEFS lump
-l = WAD_LL_LINEDEFS;
-lump_offset[WAD_LL_LINEDEFS] = ftell (file);
-for (n = 0; n < NumLineDefs; n++)
-   {
-   file_write_i16 (file, LineDefs[n].start   );
-   file_write_i16 (file, LineDefs[n].end     );
-   file_write_i16 (file, LineDefs[n].flags   );
-   file_write_i16 (file, LineDefs[n].type    );
-   file_write_i16 (file, LineDefs[n].tag     );
-   file_write_i16 (file, LineDefs[n].sidedef1);
-   file_write_i16 (file, LineDefs[n].sidedef2);
-   }
-lump_size[l] = ftell (file) - lump_offset[l];
-if (Level)
-   dir = dir->next;
+    l = WAD_LL_LINEDEFS;
+    lump_offset[WAD_LL_LINEDEFS] = ftell(file);
+    for (n = 0; n < NumLineDefs; n++)
+    {
+	file_write_i16(file, LineDefs[n].start);
+	file_write_i16(file, LineDefs[n].end);
+	file_write_i16(file, LineDefs[n].flags);
+	file_write_i16(file, LineDefs[n].type);
+	file_write_i16(file, LineDefs[n].tag);
+	file_write_i16(file, LineDefs[n].sidedef1);
+	file_write_i16(file, LineDefs[n].sidedef2);
+    }
+    lump_size[l] = ftell(file) - lump_offset[l];
+    if (Level)
+	dir = dir->next;
 
 // Write the SIDEDEFS lump
-l = WAD_LL_SIDEDEFS;
-lump_offset[l] = ftell (file);
-for (n = 0; n < NumSideDefs; n++)
-   {
-   file_write_i16 (file, SideDefs[n].xoff);
-   file_write_i16 (file, SideDefs[n].yoff);
-   WriteBytes     (file, &(SideDefs[n].tex1), WAD_TEX_NAME);
-   WriteBytes     (file, &(SideDefs[n].tex2), WAD_TEX_NAME);
-   WriteBytes     (file, &(SideDefs[n].tex3), WAD_TEX_NAME);
-   file_write_i16 (file, SideDefs[n].sector);
-   }
-lump_size[l] = ftell (file) - lump_offset[l];
-if (Level)
-   dir = dir->next;
+    l = WAD_LL_SIDEDEFS;
+    lump_offset[l] = ftell(file);
+    for (n = 0; n < NumSideDefs; n++)
+    {
+	file_write_i16(file, SideDefs[n].xoff);
+	file_write_i16(file, SideDefs[n].yoff);
+	WriteBytes(file, &(SideDefs[n].tex1), WAD_TEX_NAME);
+	WriteBytes(file, &(SideDefs[n].tex2), WAD_TEX_NAME);
+	WriteBytes(file, &(SideDefs[n].tex3), WAD_TEX_NAME);
+	file_write_i16(file, SideDefs[n].sector);
+    }
+    lump_size[l] = ftell(file) - lump_offset[l];
+    if (Level)
+	dir = dir->next;
 
 // Write the VERTEXES lump
-l = WAD_LL_VERTEXES;
-lump_offset[WAD_LL_VERTEXES] = ftell (file);
-if (reuse_nodes)
-   {
-   /* Copy the vertices */
-   const Wad_file *wf = dir->wadfile;
-   wf->seek (dir->dir.start);
-   if (wf->error ())
-      {
-      warn ("%s: seek error\n", wad_level_lump[l]);
-      }
-   copy_bytes (file, wf->fp, dir->dir.size);
-   }
-else
-   {
-   /* Write the vertices */
-   for (n = 0; n < NumVertices; n++)
-      {
-      file_write_i16 (file, Vertices[n].x);
-      file_write_i16 (file, Vertices[n].y);
-      }
-   }
-lump_size[l] = ftell (file) - lump_offset[l];
-if (Level)
-   dir = dir->next;
+    l = WAD_LL_VERTEXES;
+    lump_offset[WAD_LL_VERTEXES] = ftell(file);
+    if (reuse_nodes)
+    {
+	/* Copy the vertices */
+	const Wad_file *wf = dir->wadfile;
+	wf->seek(dir->dir.start);
+	if (wf->error())
+	{
+	    warn("%s: seek error\n", wad_level_lump[l]);
+	}
+	copy_bytes(file, wf->fp, dir->dir.size);
+    }
+    else
+    {
+	/* Write the vertices */
+	for (n = 0; n < NumVertices; n++)
+	{
+	    file_write_i16(file, Vertices[n].x);
+	    file_write_i16(file, Vertices[n].y);
+	}
+    }
+    lump_size[l] = ftell(file) - lump_offset[l];
+    if (Level)
+	dir = dir->next;
 
 // Write the SEGS, SSECTORS and NODES lumps
-for (n = 0; n < 3; n++)
-   {
-   if (n == 0)
-      l = WAD_LL_SEGS;
-   else if (n == 1)
-      l = WAD_LL_SSECTORS;
-   else if (n == 2)
-      l = WAD_LL_NODES;
-   lump_offset[l] = ftell (file);
-   if (reuse_nodes)
-      {
-      const Wad_file *wf = dir->wadfile;
-      wf->seek (dir->dir.start);
-      if (wf->error ())
-	 {
-	 warn ("%s: seek error\n", wad_level_lump[l]);
-	 }
-      copy_bytes (file, wf->fp, dir->dir.size);
-      }
-   lump_size[l] = ftell (file) - lump_offset[l];
-   if (Level)
-      dir = dir->next;
-   }
+    for (n = 0; n < 3; n++)
+    {
+	if (n == 0)
+	    l = WAD_LL_SEGS;
+	else if (n == 1)
+	    l = WAD_LL_SSECTORS;
+	else if (n == 2)
+	    l = WAD_LL_NODES;
+	lump_offset[l] = ftell(file);
+	if (reuse_nodes)
+	{
+	    const Wad_file *wf = dir->wadfile;
+	    wf->seek(dir->dir.start);
+	    if (wf->error())
+	    {
+		warn("%s: seek error\n", wad_level_lump[l]);
+	    }
+	    copy_bytes(file, wf->fp, dir->dir.size);
+	}
+	lump_size[l] = ftell(file) - lump_offset[l];
+	if (Level)
+	    dir = dir->next;
+    }
 
 // Write the SECTORS lump
-l = WAD_LL_SECTORS;
-lump_offset[l] = ftell (file);
-for (n = 0; n < NumSectors; n++)
-   {
-   file_write_i16 (file, Sectors[n].floorh);
-   file_write_i16 (file, Sectors[n].ceilh );
-   WriteBytes     (file, Sectors[n].floort, WAD_FLAT_NAME);
-   WriteBytes     (file, Sectors[n].ceilt,  WAD_FLAT_NAME);
-   file_write_i16 (file, Sectors[n].light  );
-   file_write_i16 (file, Sectors[n].special);
-   file_write_i16 (file, Sectors[n].tag    );
-   }
-lump_size[l] = ftell (file) - lump_offset[l];
-if (Level)
-   dir = dir->next;
+    l = WAD_LL_SECTORS;
+    lump_offset[l] = ftell(file);
+    for (n = 0; n < NumSectors; n++)
+    {
+	file_write_i16(file, Sectors[n].floorh);
+	file_write_i16(file, Sectors[n].ceilh);
+	WriteBytes(file, Sectors[n].floort, WAD_FLAT_NAME);
+	WriteBytes(file, Sectors[n].ceilt, WAD_FLAT_NAME);
+	file_write_i16(file, Sectors[n].light);
+	file_write_i16(file, Sectors[n].special);
+	file_write_i16(file, Sectors[n].tag);
+    }
+    lump_size[l] = ftell(file) - lump_offset[l];
+    if (Level)
+	dir = dir->next;
 
 // Write the REJECT lump
-l = WAD_LL_REJECT;
-lump_offset[l] = ftell (file);
-if (reuse_nodes)
-   {
-   /* Copy the REJECT data */
-   const Wad_file *wf = dir->wadfile;
-   wf->seek (dir->dir.start);
-   if (wf->error ())
-      {
-      warn ("%s: seek error\n", wad_level_lump[l]);
-      }
-   copy_bytes (file, wf->fp, dir->dir.size);
-   }
-lump_size[l] = ftell (file) - lump_offset[l];
-if (Level)
-   dir = dir->next;
+    l = WAD_LL_REJECT;
+    lump_offset[l] = ftell(file);
+    if (reuse_nodes)
+    {
+	/* Copy the REJECT data */
+	const Wad_file *wf = dir->wadfile;
+	wf->seek(dir->dir.start);
+	if (wf->error())
+	{
+	    warn("%s: seek error\n", wad_level_lump[l]);
+	}
+	copy_bytes(file, wf->fp, dir->dir.size);
+    }
+    lump_size[l] = ftell(file) - lump_offset[l];
+    if (Level)
+	dir = dir->next;
 
 // Write the BLOCKMAP lump
-l = WAD_LL_BLOCKMAP;
-lump_offset[l] = ftell (file);
-if (reuse_nodes)
-   {
-   const Wad_file *wf = dir->wadfile;
-   wf->seek (dir->dir.start);
-   if (wf->error ())
-      {
-      warn ("%s: seek error\n", wad_level_lump[l]);
-      }
-   copy_bytes (file, wf->fp, dir->dir.size);
-   }
-lump_size[l] = ftell (file) - lump_offset[l];
-if (Level)
-   dir = dir->next;
+    l = WAD_LL_BLOCKMAP;
+    lump_offset[l] = ftell(file);
+    if (reuse_nodes)
+    {
+	const Wad_file *wf = dir->wadfile;
+	wf->seek(dir->dir.start);
+	if (wf->error())
+	{
+	    warn("%s: seek error\n", wad_level_lump[l]);
+	}
+	copy_bytes(file, wf->fp, dir->dir.size);
+    }
+    lump_size[l] = ftell(file) - lump_offset[l];
+    if (Level)
+	dir = dir->next;
 
 // Write the actual directory
-long dir_offset = ftell (file);
-for (int L = 0; L < (int) WAD_LL__; L++)
-   {
-   file_write_i32 (file, lump_offset[L]);
-   file_write_i32 (file, lump_size[L]);
-   if (L == (int) WAD_LL_LABEL)
-      file_write_name (file, level_name);
-   else
-      file_write_name (file, wad_level_lump[L].name);
-   }
+    long dir_offset = ftell(file);
+    for (int L = 0; L < (int) WAD_LL__; L++)
+    {
+	file_write_i32(file, lump_offset[L]);
+	file_write_i32(file, lump_size[L]);
+	if (L == (int) WAD_LL_LABEL)
+	    file_write_name(file, level_name);
+	else
+	    file_write_name(file, wad_level_lump[L].name);
+    }
 
 /* Fix up the directory start information */
-if (fseek (file, 8, SEEK_SET))
-   {
-   char buf1[81];
-   char buf2[81];
-   y_snprintf (buf1, sizeof buf1, "%.64s: seek error", outfile);
-   y_snprintf (buf2, sizeof buf2, "(%.64s)",           strerror (errno));
-   Notify (-1, -1, buf1, buf2);
-   fclose (file);
-   return 1;
-   }
-file_write_i32 (file, dir_offset);
+    if (fseek(file, 8, SEEK_SET))
+    {
+	char buf1[81];
+	char buf2[81];
+	y_snprintf(buf1, sizeof buf1, "%.64s: seek error", outfile);
+	y_snprintf(buf2, sizeof buf2, "(%.64s)", strerror(errno));
+	Notify(-1, -1, buf1, buf2);
+	fclose(file);
+	return 1;
+    }
+    file_write_i32(file, dir_offset);
 
 /* Close the file */
-if (fclose (file))
-   {
-   char buf1[81];
-   char buf2[81];
-   y_snprintf (buf1, sizeof buf1, "%.64s: write error", outfile);
-   y_snprintf (buf2, sizeof buf2, "(%.64s)",            strerror (errno));
-   Notify (-1, -1, buf1, buf2);
-   return 1;
-   }
+    if (fclose(file))
+    {
+	char buf1[81];
+	char buf2[81];
+	y_snprintf(buf1, sizeof buf1, "%.64s: write error", outfile);
+	y_snprintf(buf2, sizeof buf2, "(%.64s)", strerror(errno));
+	Notify(-1, -1, buf1, buf2);
+	return 1;
+    }
 
 /* The file is now up to date */
-if (! Level || MadeMapChanges)
-   remind_to_build_nodes = 1;
-MadeChanges = 0;
-MadeMapChanges = 0;
+    if (!Level || MadeMapChanges)
+	remind_to_build_nodes = 1;
+    MadeChanges = 0;
+    MadeMapChanges = 0;
 
 /* Update pointers in Master Directory */
-OpenPatchWad (outfile);
+    OpenPatchWad(outfile);
 
 /* This should free the old "*.bak" file */
-CloseUnusedWadFiles ();
+    CloseUnusedWadFiles();
 
 /* Update MapMinX, MapMinY, MapMaxX, MapMaxY */
 // Probably not necessary anymore -- AYM 1999-04-05
-update_level_bounds ();
-return 0;
+    update_level_bounds();
+    return 0;
 }
 
 
@@ -1264,245 +1276,249 @@
  *	Function used by qsort() to sort the flat_list_entry array
  *	by ascending flat name.
  */
-static int flat_list_entry_cmp (const void *a, const void *b)
+static int flat_list_entry_cmp(const void *a, const void *b)
 {
-return y_strnicmp (
-    ((const flat_list_entry_t *) a)->name,
-    ((const flat_list_entry_t *) b)->name,
-    WAD_FLAT_NAME);
+    return y_strnicmp(((const flat_list_entry_t *) a)->name,
+		      ((const flat_list_entry_t *) b)->name, WAD_FLAT_NAME);
 }
 
 
 /*
    function used by qsort to sort the texture names
 */
-static int SortTextures (const void *a, const void *b)
+static int SortTextures(const void *a, const void *b)
 {
-return y_strnicmp (*((const char *const *)a), *((const char *const *)b),
-    WAD_TEX_NAME);
+    return y_strnicmp(*((const char *const *) a), *((const char *const *) b),
+		      WAD_TEX_NAME);
 }
 
 
 /*
    read the texture names
 */
-void ReadWTextureNames ()
+void ReadWTextureNames()
 {
-MDirPtr dir;
-int n;
-i32 val;
+    MDirPtr dir;
+    int n;
+    i32 val;
 
-verbmsg ("Reading texture names\n");
+    verbmsg("Reading texture names\n");
 
 // Doom alpha 0.4 : "TEXTURES", no names
-if (yg_texture_lumps == YGTL_TEXTURES
- && yg_texture_format == YGTF_NAMELESS)
-   {
-   const char *lump_name = "TEXTURES";
-   dir = FindMasterDir (MasterDir, lump_name);
-   if (dir == NULL)
-      {
-      warn ("%s: lump not found in directory\n", lump_name);
-      goto textures04_done;
-      }
-   {
-   const Wad_file *wf = dir->wadfile;
-   wf->seek (dir->dir.start);
-   if (wf->error ())
-      {
-      warn ("%s: seek error\n", lump_name);
-      goto textures04_done;
-      }
-   wf->read_i32 (&val);
-   if (wf->error ())
-      {
-      warn ("%s: error reading texture count\n", lump_name);
-      goto textures04_done;
-      }
-   NumWTexture = (int) val + 1;
-   WTexture = (char **) GetMemory ((long) NumWTexture * sizeof *WTexture);
-   WTexture[0] = (char *) GetMemory (WAD_TEX_NAME + 1);
-   strcpy (WTexture[0], "-");
-   if (WAD_TEX_NAME < 7) nf_bug ("WAD_TEX_NAME too small");  // Sanity
-   for (long n = 0; n < val; n++)
-      {
-      WTexture[n + 1] = (char *) GetMemory (WAD_TEX_NAME + 1);
-      if (n > 9999)
-	 {
-	 warn ("more than 10,000 textures. Ignoring excess.\n");
-	 break;
-	 }
-      sprintf (WTexture[n + 1], "TEX%04ld", n);
-      }
-   }
-   textures04_done:
-   ;
-   }
+    if (yg_texture_lumps == YGTL_TEXTURES
+	&& yg_texture_format == YGTF_NAMELESS)
+    {
+	const char *lump_name = "TEXTURES";
+	dir = FindMasterDir(MasterDir, lump_name);
+	if (dir == NULL)
+	{
+	    warn("%s: lump not found in directory\n", lump_name);
+	    goto textures04_done;
+	}
+	{
+	    const Wad_file *wf = dir->wadfile;
+	    wf->seek(dir->dir.start);
+	    if (wf->error())
+	    {
+		warn("%s: seek error\n", lump_name);
+		goto textures04_done;
+	    }
+	    wf->read_i32(&val);
+	    if (wf->error())
+	    {
+		warn("%s: error reading texture count\n", lump_name);
+		goto textures04_done;
+	    }
+	    NumWTexture = (int) val + 1;
+	    WTexture =
+		(char **) GetMemory((long) NumWTexture * sizeof *WTexture);
+	    WTexture[0] = (char *) GetMemory(WAD_TEX_NAME + 1);
+	    strcpy(WTexture[0], "-");
+	    if (WAD_TEX_NAME < 7)
+		nf_bug("WAD_TEX_NAME too small");	// Sanity
+	    for (long n = 0; n < val; n++)
+	    {
+		WTexture[n + 1] = (char *) GetMemory(WAD_TEX_NAME + 1);
+		if (n > 9999)
+		{
+		    warn("more than 10,000 textures. Ignoring excess.\n");
+		    break;
+		}
+		sprintf(WTexture[n + 1], "TEX%04ld", n);
+	    }
+	}
+      textures04_done:
+	;
+    }
 
 // Doom alpha 0.5 : only "TEXTURES"
-else if (yg_texture_lumps == YGTL_TEXTURES
-      && (yg_texture_format == YGTF_NORMAL
-	  || yg_texture_format == YGTF_STRIFE11))
-   {
-   const char *lump_name = "TEXTURES";
-   i32 *offsets = 0;
-   dir = FindMasterDir (MasterDir, lump_name);
-   if (dir == NULL)  // In theory it always exists, though
-      {
-      warn ("%s: lump not found in directory\n", lump_name);
-      goto textures05_done;
-      }
-   {
-   const Wad_file *wf = dir->wadfile;
-   wf->seek (dir->dir.start);
-   if (wf->error ())
-      {
-      warn ("%s: seek error\n", lump_name);
-      goto textures05_done;
-      }
-   wf->read_i32 (&val);
-   if (wf->error ())
-      {
-      warn ("%s: error reading texture count\n", lump_name);
-      goto textures05_done;
-      }
-   NumWTexture = (int) val + 1;
-   /* read in the offsets for texture1 names */
-   offsets = (i32 *) GetMemory ((long) NumWTexture * 4);
-   wf->read_i32 (offsets + 1, NumWTexture - 1);
-   if (wf->error ())
-      {
-      warn ("%s: error reading offsets table\n", lump_name);
-      goto textures05_done;
-      }
-   /* read in the actual names */
-   WTexture = (char **) GetMemory ((long) NumWTexture * sizeof (char *));
-   WTexture[0] = (char *) GetMemory (WAD_TEX_NAME + 1);
-   strcpy (WTexture[0], "-");
-   for (n = 1; n < NumWTexture; n++)
-      {
-      WTexture[n] = (char *) GetMemory (WAD_TEX_NAME + 1);
-      long offset = dir->dir.start + offsets[n];
-      wf->seek (offset);
-      if (wf->error ())
-	 {
-	 warn ("%s: error seeking to  error\n", lump_name);
-	 goto textures05_done;		// FIXME cleanup
-	 }
-      wf->read_bytes (WTexture[n], WAD_TEX_NAME);
-      if (wf->error ())
-	 {
-	 warn ("%s: error reading texture names\n", lump_name);
-	 goto textures05_done;		// FIXME cleanup
-	 }
-      WTexture[n][WAD_TEX_NAME] = '\0';
-      }
-   }
-   textures05_done:
-   if (offsets != 0)
-      FreeMemory (offsets);
-   }
+    else if (yg_texture_lumps == YGTL_TEXTURES
+	     && (yg_texture_format == YGTF_NORMAL
+		 || yg_texture_format == YGTF_STRIFE11))
+    {
+	const char *lump_name = "TEXTURES";
+	i32 *offsets = 0;
+	dir = FindMasterDir(MasterDir, lump_name);
+	if (dir == NULL)	// In theory it always exists, though
+	{
+	    warn("%s: lump not found in directory\n", lump_name);
+	    goto textures05_done;
+	}
+	{
+	    const Wad_file *wf = dir->wadfile;
+	    wf->seek(dir->dir.start);
+	    if (wf->error())
+	    {
+		warn("%s: seek error\n", lump_name);
+		goto textures05_done;
+	    }
+	    wf->read_i32(&val);
+	    if (wf->error())
+	    {
+		warn("%s: error reading texture count\n", lump_name);
+		goto textures05_done;
+	    }
+	    NumWTexture = (int) val + 1;
+	    /* read in the offsets for texture1 names */
+	    offsets = (i32 *) GetMemory((long) NumWTexture * 4);
+	    wf->read_i32(offsets + 1, NumWTexture - 1);
+	    if (wf->error())
+	    {
+		warn("%s: error reading offsets table\n", lump_name);
+		goto textures05_done;
+	    }
+	    /* read in the actual names */
+	    WTexture =
+		(char **) GetMemory((long) NumWTexture * sizeof(char *));
+	    WTexture[0] = (char *) GetMemory(WAD_TEX_NAME + 1);
+	    strcpy(WTexture[0], "-");
+	    for (n = 1; n < NumWTexture; n++)
+	    {
+		WTexture[n] = (char *) GetMemory(WAD_TEX_NAME + 1);
+		long offset = dir->dir.start + offsets[n];
+		wf->seek(offset);
+		if (wf->error())
+		{
+		    warn("%s: error seeking to  error\n", lump_name);
+		    goto textures05_done;	// FIXME cleanup
+		}
+		wf->read_bytes(WTexture[n], WAD_TEX_NAME);
+		if (wf->error())
+		{
+		    warn("%s: error reading texture names\n", lump_name);
+		    goto textures05_done;	// FIXME cleanup
+		}
+		WTexture[n][WAD_TEX_NAME] = '\0';
+	    }
+	}
+      textures05_done:
+	if (offsets != 0)
+	    FreeMemory(offsets);
+    }
 // Other iwads : "TEXTURE1" and possibly "TEXTURE2"
-else if (yg_texture_lumps == YGTL_NORMAL
-      && (yg_texture_format == YGTF_NORMAL
-	  || yg_texture_format == YGTF_STRIFE11))
-   {
-   const char *lump_name = "TEXTURE1";
-   i32 *offsets = 0;
-   dir = FindMasterDir (MasterDir, lump_name);
-   if (dir != NULL)  // In theory it always exists, though
-      {
-      const Wad_file *wf = dir->wadfile;
-      wf->seek (dir->dir.start);
-      if (wf->error ())
-	 {
-	 warn ("%s: seek error\n", lump_name);
-	 // FIXME
-	 }
-      wf->read_i32 (&val);
-      if (wf->error ())
-      {
-	// FIXME
-      }
-      NumWTexture = (int) val + 1;
-      /* read in the offsets for texture1 names */
-      offsets = (i32 *) GetMemory ((long) NumWTexture * 4);
-      wf->read_i32 (offsets + 1, NumWTexture - 1);
-      {
-	// FIXME
-      }
-      /* read in the actual names */
-      WTexture = (char **) GetMemory ((long) NumWTexture * sizeof (char *));
-      WTexture[0] = (char *) GetMemory (WAD_TEX_NAME + 1);
-      strcpy (WTexture[0], "-");
-      for (n = 1; n < NumWTexture; n++)
-	 {
-	 WTexture[n] = (char *) GetMemory (WAD_TEX_NAME + 1);
-	 wf->seek (dir->dir.start + offsets[n]);
-	 if (wf->error ())
+    else if (yg_texture_lumps == YGTL_NORMAL
+	     && (yg_texture_format == YGTF_NORMAL
+		 || yg_texture_format == YGTF_STRIFE11))
+    {
+	const char *lump_name = "TEXTURE1";
+	i32 *offsets = 0;
+	dir = FindMasterDir(MasterDir, lump_name);
+	if (dir != NULL)	// In theory it always exists, though
+	{
+	    const Wad_file *wf = dir->wadfile;
+	    wf->seek(dir->dir.start);
+	    if (wf->error())
+	    {
+		warn("%s: seek error\n", lump_name);
+		// FIXME
+	    }
+	    wf->read_i32(&val);
+	    if (wf->error())
 	    {
-	    warn ("%s: seek error\n", lump_name);
-	    // FIXME
+		// FIXME
+	    }
+	    NumWTexture = (int) val + 1;
+	    /* read in the offsets for texture1 names */
+	    offsets = (i32 *) GetMemory((long) NumWTexture * 4);
+	    wf->read_i32(offsets + 1, NumWTexture - 1);
+	    {
+		// FIXME
 	    }
-	 wf->read_bytes (WTexture[n], WAD_TEX_NAME);
-	 if (wf->error ())
+	    /* read in the actual names */
+	    WTexture =
+		(char **) GetMemory((long) NumWTexture * sizeof(char *));
+	    WTexture[0] = (char *) GetMemory(WAD_TEX_NAME + 1);
+	    strcpy(WTexture[0], "-");
+	    for (n = 1; n < NumWTexture; n++)
 	    {
-	      // FIXME
+		WTexture[n] = (char *) GetMemory(WAD_TEX_NAME + 1);
+		wf->seek(dir->dir.start + offsets[n]);
+		if (wf->error())
+		{
+		    warn("%s: seek error\n", lump_name);
+		    // FIXME
+		}
+		wf->read_bytes(WTexture[n], WAD_TEX_NAME);
+		if (wf->error())
+		{
+		    // FIXME
+		}
+		WTexture[n][WAD_TEX_NAME] = '\0';
 	    }
-	 WTexture[n][WAD_TEX_NAME] = '\0';
-	 }
-      FreeMemory (offsets);
-      }
-   {
-   dir = FindMasterDir (MasterDir, "TEXTURE2");
-   if (dir)  /* Doom II has no TEXTURE2 */
-      {
-      const Wad_file *wf = dir->wadfile;
-      wf->seek (dir->dir.start);
-      if (wf->error ())
-	 {
-	 warn ("%s: seek error\n", lump_name);
-	 // FIXME
-	 }
-      wf->read_i32 (&val);
-      if (wf->error ())
-      {
-	// FIXME
-      }
-      /* read in the offsets for texture2 names */
-      offsets = (i32 *) GetMemory ((long) val * 4);
-      wf->read_i32 (offsets, val);
-      if (wf->error ())
-      {
-	// FIXME
-      }
-      /* read in the actual names */
-      WTexture = (char **) ResizeMemory (WTexture,
-	 (NumWTexture + val) * sizeof (char *));
-      for (n = 0; n < val; n++)
-	 {
-	 WTexture[NumWTexture + n] = (char *) GetMemory (WAD_TEX_NAME + 1);
-	 wf->seek (dir->dir.start + offsets[n]);
-	 if (wf->error ())
+	    FreeMemory(offsets);
+	}
+	{
+	    dir = FindMasterDir(MasterDir, "TEXTURE2");
+	    if (dir)		/* Doom II has no TEXTURE2 */
 	    {
-	    warn ("%s: seek error\n", lump_name);
-	    // FIXME
+		const Wad_file *wf = dir->wadfile;
+		wf->seek(dir->dir.start);
+		if (wf->error())
+		{
+		    warn("%s: seek error\n", lump_name);
+		    // FIXME
+		}
+		wf->read_i32(&val);
+		if (wf->error())
+		{
+		    // FIXME
+		}
+		/* read in the offsets for texture2 names */
+		offsets = (i32 *) GetMemory((long) val * 4);
+		wf->read_i32(offsets, val);
+		if (wf->error())
+		{
+		    // FIXME
+		}
+		/* read in the actual names */
+		WTexture = (char **) ResizeMemory(WTexture,
+						  (NumWTexture +
+						   val) * sizeof(char *));
+		for (n = 0; n < val; n++)
+		{
+		    WTexture[NumWTexture + n] =
+			(char *) GetMemory(WAD_TEX_NAME + 1);
+		    wf->seek(dir->dir.start + offsets[n]);
+		    if (wf->error())
+		    {
+			warn("%s: seek error\n", lump_name);
+			// FIXME
+		    }
+		    wf->read_bytes(WTexture[NumWTexture + n], WAD_TEX_NAME);
+		    if (wf->error())
+			;	// FIXME
+		    WTexture[NumWTexture + n][WAD_TEX_NAME] = '\0';
+		}
+		NumWTexture += val;
+		FreeMemory(offsets);
 	    }
-	 wf->read_bytes (WTexture[NumWTexture + n], WAD_TEX_NAME);
-	 if (wf->error ())
-	   ; // FIXME
-	 WTexture[NumWTexture + n][WAD_TEX_NAME] = '\0';
-	 }
-      NumWTexture += val;
-      FreeMemory (offsets);
-      }
-   }
-   }
-else
-   nf_bug ("Invalid texture_format/texture_lumps combination.");
+	}
+    }
+    else
+	nf_bug("Invalid texture_format/texture_lumps combination.");
 
 /* sort the names */
-qsort (WTexture, NumWTexture, sizeof (char *), SortTextures);
+    qsort(WTexture, NumWTexture, sizeof(char *), SortTextures);
 }
 
 
@@ -1511,17 +1527,17 @@
    forget the texture names
 */
 
-void ForgetWTextureNames ()
+void ForgetWTextureNames()
 {
-int n;
+    int n;
 
 /* forget all names */
-for (n = 0; n < NumWTexture; n++)
-   FreeMemory (WTexture[n]);
+    for (n = 0; n < NumWTexture; n++)
+	FreeMemory(WTexture[n]);
 
 /* forget the array */
-NumWTexture = 0;
-FreeMemory (WTexture);
+    NumWTexture = 0;
+    FreeMemory(WTexture);
 }
 
 
@@ -1530,110 +1546,116 @@
    read the flat names
 */
 
-void ReadFTextureNames ()
+void ReadFTextureNames()
 {
-MDirPtr dir;
-int n;
+    MDirPtr dir;
+    int n;
 
-verbmsg ("Reading flat names");
-NumFTexture = 0;
+    verbmsg("Reading flat names");
+    NumFTexture = 0;
 
-for (dir = MasterDir; (dir = FindMasterDir (dir, "F_START", "FF_START"));)
-   {
-   bool ff_start = ! y_strnicmp (dir->dir.name, "FF_START", WAD_NAME);
-   MDirPtr dir0;
-   /* count the names */
-   dir = dir->next;
-   dir0 = dir;
-   for (n = 0; dir && y_strnicmp (dir->dir.name, "F_END", WAD_NAME)
-	 && (! ff_start || y_strnicmp (dir->dir.name, "FF_END", WAD_NAME));
-	 dir = dir->next)
-      {
-      if (dir->dir.start == 0 || dir->dir.size == 0)
-	 {
-	 if (! (toupper (dir->dir.name[0]) == 'F'
-	     && (dir->dir.name[1] == '1'
-	      || dir->dir.name[1] == '2'
-	      || dir->dir.name[1] == '3'
-	      || toupper (dir->dir.name[1]) == 'F')
-	     && dir->dir.name[2] == '_'
-	     && (! y_strnicmp (dir->dir.name + 3, "START", WAD_NAME - 3)
-		 || ! y_strnicmp (dir->dir.name + 3, "END", WAD_NAME - 3))))
-	    warn ("unexpected label \"%.*s\" among flats.\n",
-		  WAD_NAME, dir->dir.name);
-	 continue;
-	 }
-      if (dir->dir.size != 4096)
-	 warn ("flat \"%.*s\" has weird size %lu."
-	     " Using 4096 instead.\n",
-	       WAD_NAME, dir->dir.name, (unsigned long) dir->dir.size);
-      n++;
-      }
-   /* If FF_START/FF_END followed by F_END (mm2.wad), advance
-      past F_END. In fact, this does not work because the F_END
-      that follows has been snatched by OpenPatchWad(), that
-      thinks it replaces the F_END from the iwad. OpenPatchWad()
-      needs to be kludged to take this special case into
-      account. Fortunately, the only consequence is a useless
-      "this wad uses FF_END" warning. -- AYM 1999-07-10 */
-   if (ff_start && dir && ! y_strnicmp (dir->dir.name, "FF_END", WAD_NAME))
-      if (dir->next && ! y_strnicmp (dir->next->dir.name, "F_END", WAD_NAME))
-         dir = dir->next;
+    for (dir = MasterDir; (dir = FindMasterDir(dir, "F_START", "FF_START"));)
+    {
+	bool ff_start = !y_strnicmp(dir->dir.name, "FF_START", WAD_NAME);
+	MDirPtr dir0;
+	/* count the names */
+	dir = dir->next;
+	dir0 = dir;
+	for (n = 0; dir && y_strnicmp(dir->dir.name, "F_END", WAD_NAME)
+	     && (!ff_start || y_strnicmp(dir->dir.name, "FF_END", WAD_NAME));
+	     dir = dir->next)
+	{
+	    if (dir->dir.start == 0 || dir->dir.size == 0)
+	    {
+		if (!(toupper(dir->dir.name[0]) == 'F'
+		      && (dir->dir.name[1] == '1'
+			  || dir->dir.name[1] == '2'
+			  || dir->dir.name[1] == '3'
+			  || toupper(dir->dir.name[1]) == 'F')
+		      && dir->dir.name[2] == '_'
+		      &&
+		      (!y_strnicmp(dir->dir.name + 3, "START", WAD_NAME - 3)
+		       || !y_strnicmp(dir->dir.name + 3, "END",
+				      WAD_NAME - 3))))
+		    warn("unexpected label \"%.*s\" among flats.\n", WAD_NAME,
+			 dir->dir.name);
+		continue;
+	    }
+	    if (dir->dir.size != 4096)
+		warn("flat \"%.*s\" has weird size %lu."
+		     " Using 4096 instead.\n",
+		     WAD_NAME, dir->dir.name, (unsigned long) dir->dir.size);
+	    n++;
+	}
+	/* If FF_START/FF_END followed by F_END (mm2.wad), advance
+	   past F_END. In fact, this does not work because the F_END
+	   that follows has been snatched by OpenPatchWad(), that
+	   thinks it replaces the F_END from the iwad. OpenPatchWad()
+	   needs to be kludged to take this special case into
+	   account. Fortunately, the only consequence is a useless
+	   "this wad uses FF_END" warning. -- AYM 1999-07-10 */
+	if (ff_start && dir && !y_strnicmp(dir->dir.name, "FF_END", WAD_NAME))
+	    if (dir->next
+		&& !y_strnicmp(dir->next->dir.name, "F_END", WAD_NAME))
+		dir = dir->next;
 
-   verbmsg (" FF_START/%s %d", dir->dir.name, n);
-   if (dir && ! y_strnicmp (dir->dir.name, "FF_END", WAD_NAME))
-      warn ("this wad uses FF_END. That won't work with Doom."
-	 " Use F_END instead.\n");
-   /* get the actual names from master dir. */
-   flat_list = (flat_list_entry_t *) ResizeMemory (flat_list,
-      (NumFTexture + n) * sizeof *flat_list);
-   for (size_t m = NumFTexture; m < NumFTexture + n; dir0 = dir0->next)
-      {
-      // Skip all labels.
-      if (dir0->dir.start == 0
-	 || dir0->dir.size == 0
-	 || (toupper (dir0->dir.name[0]) == 'F'
-	     && (dir0->dir.name[1] == '1'
-	      || dir0->dir.name[1] == '2'
-	      || dir0->dir.name[1] == '3'
-	      || toupper (dir0->dir.name[1]) == 'F')
-	     && dir0->dir.name[2] == '_'
-	     && (! y_strnicmp (dir0->dir.name + 3, "START", WAD_NAME - 3)
-		 || ! y_strnicmp (dir0->dir.name + 3, "END", WAD_NAME - 3))
-	     ))
-	 continue;
-      *flat_list[m].name = '\0';
-      strncat (flat_list[m].name, dir0->dir.name, sizeof flat_list[m].name - 1);
-      flat_list[m].wadfile = dir0->wadfile;
-      flat_list[m].offset  = dir0->dir.start;
-      m++;
-      }
-   NumFTexture += n;
-   }
+	verbmsg(" FF_START/%s %d", dir->dir.name, n);
+	if (dir && !y_strnicmp(dir->dir.name, "FF_END", WAD_NAME))
+	    warn("this wad uses FF_END. That won't work with Doom."
+		 " Use F_END instead.\n");
+	/* get the actual names from master dir. */
+	flat_list = (flat_list_entry_t *) ResizeMemory(flat_list,
+						       (NumFTexture +
+							n) *
+						       sizeof *flat_list);
+	for (size_t m = NumFTexture; m < NumFTexture + n; dir0 = dir0->next)
+	{
+	    // Skip all labels.
+	    if (dir0->dir.start == 0
+		|| dir0->dir.size == 0
+		|| (toupper(dir0->dir.name[0]) == 'F'
+		    && (dir0->dir.name[1] == '1'
+			|| dir0->dir.name[1] == '2'
+			|| dir0->dir.name[1] == '3'
+			|| toupper(dir0->dir.name[1]) == 'F')
+		    && dir0->dir.name[2] == '_'
+		    && (!y_strnicmp(dir0->dir.name + 3, "START", WAD_NAME - 3)
+			|| !y_strnicmp(dir0->dir.name + 3, "END",
+				       WAD_NAME - 3))))
+		continue;
+	    *flat_list[m].name = '\0';
+	    strncat(flat_list[m].name, dir0->dir.name,
+		    sizeof flat_list[m].name - 1);
+	    flat_list[m].wadfile = dir0->wadfile;
+	    flat_list[m].offset = dir0->dir.start;
+	    m++;
+	}
+	NumFTexture += n;
+    }
 
-verbmsg ("\n");
+    verbmsg("\n");
 
 /* sort the flats by names */
-qsort (flat_list, NumFTexture, sizeof *flat_list, flat_list_entry_cmp);
+    qsort(flat_list, NumFTexture, sizeof *flat_list, flat_list_entry_cmp);
 
 /* Eliminate all but the last duplicates of a flat. Suboptimal.
    Would be smarter to start by the end. */
-for (size_t n = 0; n < NumFTexture; n++)
-   {
-   size_t m = n;
-   while (m + 1 < NumFTexture
-     && ! flat_list_entry_cmp (flat_list + n, flat_list + m + 1))
-       m++;
-   // m now contains the index of the last duplicate
-   int nduplicates = m - n;
-   if (nduplicates > 0)
-      {
-      memmove (flat_list + n, flat_list + m,
-                                      (NumFTexture - m) * sizeof *flat_list);
-      NumFTexture -= nduplicates;
-      // Note that I'm too lazy to resize flat_list...
-      }
-   }
+    for (size_t n = 0; n < NumFTexture; n++)
+    {
+	size_t m = n;
+	while (m + 1 < NumFTexture
+	       && !flat_list_entry_cmp(flat_list + n, flat_list + m + 1))
+	    m++;
+	// m now contains the index of the last duplicate
+	int nduplicates = m - n;
+	if (nduplicates > 0)
+	{
+	    memmove(flat_list + n, flat_list + m,
+		    (NumFTexture - m) * sizeof *flat_list);
+	    NumFTexture -= nduplicates;
+	    // Note that I'm too lazy to resize flat_list...
+	}
+    }
 }
 
 
@@ -1641,14 +1663,14 @@
  *	is_flat_name_in_list
  *	FIXME should use bsearch()
  */
-int is_flat_name_in_list (const char *name)
+int is_flat_name_in_list(const char *name)
 {
-  if (! flat_list)
+    if (!flat_list)
+	return 0;
+    for (size_t n = 0; n < NumFTexture; n++)
+	if (!y_strnicmp(name, flat_list[n].name, WAD_FLAT_NAME))
+	    return 1;
     return 0;
-  for (size_t n = 0; n < NumFTexture; n++)
-    if (! y_strnicmp (name, flat_list[n].name, WAD_FLAT_NAME))
-      return 1;
-  return 0;
 }
 
 
@@ -1656,35 +1678,34 @@
    forget the flat names
 */
 
-void ForgetFTextureNames ()
+void ForgetFTextureNames()
 {
-NumFTexture = 0;
-FreeMemory (flat_list);
-flat_list = 0;
+    NumFTexture = 0;
+    FreeMemory(flat_list);
+    flat_list = 0;
 }
 
 
 /*
  *	update_level_bounds - update Map{Min,Max}{X,Y}
  */
-void update_level_bounds ()
+void update_level_bounds()
 {
-MapMaxX = -32767;
-MapMaxY = -32767;
-MapMinX = 32767;
-MapMinY = 32767;
-for (obj_no_t n = 0; n < NumVertices; n++)
-   {
-   int x = Vertices[n].x;
-   if (x < MapMinX)
-      MapMinX = x;
-   if (x > MapMaxX)
-      MapMaxX = x;
-   int y = Vertices[n].y;
-   if (y < MapMinY)
-      MapMinY = y;
-   if (y > MapMaxY)
-      MapMaxY = y;
-   }
+    MapMaxX = -32767;
+    MapMaxY = -32767;
+    MapMinX = 32767;
+    MapMinY = 32767;
+    for (obj_no_t n = 0; n < NumVertices; n++)
+    {
+	int x = Vertices[n].x;
+	if (x < MapMinX)
+	    MapMinX = x;
+	if (x > MapMaxX)
+	    MapMaxX = x;
+	int y = Vertices[n].y;
+	if (y < MapMinY)
+	    MapMinY = y;
+	if (y > MapMaxY)
+	    MapMaxY = y;
+    }
 }
-
--- a/src/levels.h	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/levels.h	Sat Sep 24 14:16:04 2011 +0300
@@ -6,8 +6,8 @@
  */
 
 
-#ifndef YH_LEVELS  /* Prevent multiple inclusion */
-#define YH_LEVELS  /* Prevent multiple inclusion */
+#ifndef YH_LEVELS		/* Prevent multiple inclusion */
+#define YH_LEVELS		/* Prevent multiple inclusion */
 
 
 #include "wstructs.h"
@@ -17,76 +17,76 @@
 // Defined in levels.cc
 extern MDirPtr Level;		/* master dictionary entry for the level */
 
-extern int   NumThings;		/* number of things */
-extern TPtr  Things;		/* things data */
-extern int   NumLineDefs;	/* number of linedefs */
+extern int NumThings;		/* number of things */
+extern TPtr Things;		/* things data */
+extern int NumLineDefs;		/* number of linedefs */
 extern LDPtr LineDefs;		/* linedefs data */
-extern int   NumSideDefs;	/* number of sidedefs */
+extern int NumSideDefs;		/* number of sidedefs */
 extern SDPtr SideDefs;		/* sidedefs data */
-extern int   NumVertices;	/* number of vertices */
-extern VPtr  Vertices;		/* vertices data */
-extern int   NumSegs;		/* number of segments */
-extern int   NumSectors;	/* number of sectors */
-extern SPtr  Sectors;		/* sectors data */
+extern int NumVertices;		/* number of vertices */
+extern VPtr Vertices;		/* vertices data */
+extern int NumSegs;		/* number of segments */
+extern int NumSectors;		/* number of sectors */
+extern SPtr Sectors;		/* sectors data */
 
 // FIXME should be somewhere else
-extern int   NumWTexture;	/* number of wall textures */
-extern char  **WTexture;	/* array of wall texture names */
+extern int NumWTexture;		/* number of wall textures */
+extern char **WTexture;		/* array of wall texture names */
 extern size_t NumFTexture;	/* number of floor/ceiling textures */
 typedef struct
 {
-  char            name[WAD_NAME + 1];	// Name of flat
-  const Wad_file *wadfile;		// Pointer on wad where flat comes from
-  i32             offset;		// Offset of flat in wad
-} flat_list_entry_t;			// Length is implicit (always 4096)
+    char name[WAD_NAME + 1];	// Name of flat
+    const Wad_file *wadfile;	// Pointer on wad where flat comes from
+    i32 offset;			// Offset of flat in wad
+} flat_list_entry_t;		// Length is implicit (always 4096)
 extern flat_list_entry_t *flat_list;	// List of all flats in the directory
 
-extern int   MapMaxX;		/* maximum X value of map */
-extern int   MapMaxY;		/* maximum Y value of map */
-extern int   MapMinX;		/* minimum X value of map */
-extern int   MapMinY;		/* minimum Y value of map */
-extern bool  MadeChanges;	/* made changes? */
-extern bool  MadeMapChanges;	/* made changes that need rebuilding? */
+extern int MapMaxX;		/* maximum X value of map */
+extern int MapMaxY;		/* maximum Y value of map */
+extern int MapMinX;		/* minimum X value of map */
+extern int MapMinY;		/* minimum Y value of map */
+extern bool MadeChanges;	/* made changes? */
+extern bool MadeMapChanges;	/* made changes that need rebuilding? */
 
-extern unsigned long things_angles;  /* Used to know whether a list of
-				   things sorted by type and angle would
-				   need to be rebuilt. Incremented
-				   whenever a thing is created, deleted
-				   or has its type or angle changed.
-				   Presently, no such list exists but
-				   there will be one if
-				   draw_things_sprites() ever draws
-				   sprites according to their angles. */
+extern unsigned long things_angles;	/* Used to know whether a list of
+					   things sorted by type and angle would
+					   need to be rebuilt. Incremented
+					   whenever a thing is created, deleted
+					   or has its type or angle changed.
+					   Presently, no such list exists but
+					   there will be one if
+					   draw_things_sprites() ever draws
+					   sprites according to their angles. */
 
-extern unsigned long things_types;  /* Used to know whether the list of
-				   things sorted by type that drawmap.cc
-				   maintains should be rebuilt.
-				   Incremented whenever a thing is
-				   created, deleted or has its type
-				   changed. */
+extern unsigned long things_types;	/* Used to know whether the list of
+					   things sorted by type that drawmap.cc
+					   maintains should be rebuilt.
+					   Incremented whenever a thing is
+					   created, deleted or has its type
+					   changed. */
 
-extern char Level_name[WAD_NAME + 1]; /* The name of the level (E.G.
-				   "MAP01" or "E1M1"), followed by a
-				   NUL. If the Level has been created as
-				   the result of a "c" command with no
-				   argument, an empty string. The name
-				   is not necesarily in upper case but
-				   it always a valid lump name, not a
-				   command line shortcut like "17". */
+extern char Level_name[WAD_NAME + 1];	/* The name of the level (E.G.
+					   "MAP01" or "E1M1"), followed by a
+					   NUL. If the Level has been created as
+					   the result of a "c" command with no
+					   argument, an empty string. The name
+					   is not necesarily in upper case but
+					   it always a valid lump name, not a
+					   command line shortcut like "17". */
 
-extern y_file_name_t Level_file_name;  /* The name of the file in which
-				   the level would be saved. If the
-				   level has been created as the result
-				   of a "c" command, with or without
-				   argument, an empty string. */
+extern y_file_name_t Level_file_name;	/* The name of the file in which
+					   the level would be saved. If the
+					   level has been created as the result
+					   of a "c" command, with or without
+					   argument, an empty string. */
 
-extern y_file_name_t Level_file_name_saved;  /* The name of the file in
-				   which the level was last saved. If
-				   the Level has never been saved yet,
-				   an empty string. */
+extern y_file_name_t Level_file_name_saved;	/* The name of the file in
+						   which the level was last saved. If
+						   the Level has never been saved yet,
+						   an empty string. */
 
-void EmptyLevelData (const char *levelname);
-void update_level_bounds ();
+void EmptyLevelData(const char *levelname);
+void update_level_bounds();
 
 
-#endif	/* DO NOT ADD ANYTHING AFTER THIS LINE */
+#endif /* DO NOT ADD ANYTHING AFTER THIS LINE */
--- a/src/lists.cc	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/lists.cc	Sat Sep 24 14:16:04 2011 +0300
@@ -35,19 +35,19 @@
 
 
 // FIXME Move this in a more public place
-void lump_loc_string (char *buf, size_t buf_size, const Lump_loc& lump_loc)
+void lump_loc_string(char *buf, size_t buf_size, const Lump_loc & lump_loc)
 {
-  if (buf_size < 1)
-    return;
-  int len = buf_size - 1 - (1 + 8 + 1 + 1);  // %08lXh
-  if (len < 1)
-  {
-    *buf = '\0';
-    return;
-  }
-  y_filename (buf, len + 1, lump_loc.wad->pathname ());
-  sprintf (buf + strlen (buf), "(%08lXh)",
-    (unsigned long) lump_loc.ofs & 0xffffffff);
+    if (buf_size < 1)
+	return;
+    int len = buf_size - 1 - (1 + 8 + 1 + 1);	// %08lXh
+    if (len < 1)
+    {
+	*buf = '\0';
+	return;
+    }
+    y_filename(buf, len + 1, lump_loc.wad->pathname());
+    sprintf(buf + strlen(buf), "(%08lXh)",
+	    (unsigned long) lump_loc.ofs & 0xffffffff);
 }
 
 
@@ -75,489 +75,490 @@
 static bool disp_lump_loc = false;
 #endif
 
-void InputNameFromListWithFunc (
-   int x0,
-   int y0,
-   const char *prompt,
-   size_t listsize,
-   const char *const *list,
-   size_t listdisp,
-   char *name,
-   int width,
-   int height,
-   void (*hookfunc)(hookfunc_comm_t *),
-   char flags_to_pass_to_callback)
+void InputNameFromListWithFunc(int x0,
+			       int y0,
+			       const char *prompt,
+			       size_t listsize,
+			       const char *const *list,
+			       size_t listdisp,
+			       char *name,
+			       int width,
+			       int height,
+			       void (*hookfunc) (hookfunc_comm_t *),
+			       char flags_to_pass_to_callback)
 {
-const char *msg1 = "Press Shift-F1 to";
-const char *msg2 = "save image to file";
-int    key;
-size_t n;
-size_t win_height;
-int    win_columns;
-int    win_width;
-int    l0;
-int    x1, y1, x2, y2;
-size_t maxlen;
-int    xlist;
-bool   picture_size_drawn = false;
+    const char *msg1 = "Press Shift-F1 to";
+    const char *msg2 = "save image to file";
+    int key;
+    size_t n;
+    size_t win_height;
+    int win_columns;
+    int win_width;
+    int l0;
+    int x1, y1, x2, y2;
+    size_t maxlen;
+    int xlist;
+    bool picture_size_drawn = false;
 #ifdef DEBUG
-bool   lump_loc_drawn = false;
+    bool lump_loc_drawn = false;
 #endif
-bool   ok, firstkey;
-int    entry_out_x0;	/* Edge of name entry widget including border */
-int    entry_out_y0;
-int    entry_out_x1;
-int    entry_out_y1;
-int    entry_text_x0;	/* Edge of text area of name entry widget */
-int    entry_text_y0;
-int    entry_text_x1;
-int    entry_text_y1;
+    bool ok, firstkey;
+    int entry_out_x0;		/* Edge of name entry widget including border */
+    int entry_out_y0;
+    int entry_out_x1;
+    int entry_out_y1;
+    int entry_text_x0;		/* Edge of text area of name entry widget */
+    int entry_text_y0;
+    int entry_text_x1;
+    int entry_text_y1;
 
 // Sanity
-if (width < 0)
-{
-  nf_bug ("inflwf1");
-  width = 0;
-}
-if (height < 0)
-{
-  nf_bug ("inflwf2");
-  height = 0;
-}
+    if (width < 0)
+    {
+	nf_bug("inflwf1");
+	width = 0;
+    }
+    if (height < 0)
+    {
+	nf_bug("inflwf2");
+	height = 0;
+    }
 
 // Compute maxlen, the length of the longest item in the list
-maxlen = 1;
-for (n = 0; n < listsize; n++)
-   if (strlen (list[n]) > maxlen)
-      maxlen = strlen (list[n]);
-for (n = strlen (name) + 1; n <= maxlen; n++)
-   name[n] = '\0';
-char *namedisp = new char[maxlen + 1];
-memset (namedisp, '\xff', maxlen + 1);  // Always != from name
+    maxlen = 1;
+    for (n = 0; n < listsize; n++)
+	if (strlen(list[n]) > maxlen)
+	    maxlen = strlen(list[n]);
+    for (n = strlen(name) + 1; n <= maxlen; n++)
+	name[n] = '\0';
+    char *namedisp = new char[maxlen + 1];
+    memset(namedisp, '\xff', maxlen + 1);	// Always != from name
 
 // Compute the minimum width of the dialog box
-l0 = 12;
-if (hookfunc != NULL)
-   {
-   if ((int) (strlen (msg1) + 2) > l0)  // (int) to prevent GCC warning
-      l0 = strlen (msg1) + 2;
-   if ((int) (strlen (msg2) + 2) > l0)  // (int) to prevent GCC warning
-      l0 = strlen (msg2) + 2;
-   }
-xlist = 10 + l0 * FONTW;
-win_columns = l0 + maxlen;
-if ((int) (strlen (prompt)) > win_columns)  // (int) to prevent GCC warning
-   win_columns = strlen (prompt);
-win_width = 10 + FONTW * win_columns;
-x1 = win_width + 8;
-y1 = 10 + 1;
-if (width > 0)
-   win_width += 16 + width;
+    l0 = 12;
+    if (hookfunc != NULL)
+    {
+	if ((int) (strlen(msg1) + 2) > l0)	// (int) to prevent GCC warning
+	    l0 = strlen(msg1) + 2;
+	if ((int) (strlen(msg2) + 2) > l0)	// (int) to prevent GCC warning
+	    l0 = strlen(msg2) + 2;
+    }
+    xlist = 10 + l0 * FONTW;
+    win_columns = l0 + maxlen;
+    if ((int) (strlen(prompt)) > win_columns)	// (int) to prevent GCC warning
+	win_columns = strlen(prompt);
+    win_width = 10 + FONTW * win_columns;
+    x1 = win_width + 8;
+    y1 = 10 + 1;
+    if (width > 0)
+	win_width += 16 + width;
 // (int) to prevent GCC warning
-win_height = y_max (height + 20, (int) (listdisp * FONTH + 10 + 28));
-if (x0 < 0)
-   x0 = (ScrMaxX - win_width) / 2;
-if (y0 < 0)
-   y0 = (ScrMaxY - win_height) / 2;
-x1 += x0;
-y1 += y0;
-if (x1 + width - 1 < ScrMaxX)
-   x2 = x1 + width - 1;
-else
-   x2 = ScrMaxX;
-if (y1 + height - 1 < ScrMaxY)
-   y2 = y1 + height - 1;
-else
-   y2 = ScrMaxY;
+    win_height = y_max(height + 20, (int) (listdisp * FONTH + 10 + 28));
+    if (x0 < 0)
+	x0 = (ScrMaxX - win_width) / 2;
+    if (y0 < 0)
+	y0 = (ScrMaxY - win_height) / 2;
+    x1 += x0;
+    y1 += y0;
+    if (x1 + width - 1 < ScrMaxX)
+	x2 = x1 + width - 1;
+    else
+	x2 = ScrMaxX;
+    if (y1 + height - 1 < ScrMaxY)
+	y2 = y1 + height - 1;
+    else
+	y2 = ScrMaxY;
 
-entry_out_x0  = x0 + 10;
-entry_text_x0 = entry_out_x0 + HOLLOW_BORDER + NARROW_HSPACING;
-entry_text_x1 = entry_text_x0 + 10 * FONTW - 1;
-entry_out_x1  = entry_text_x1 + HOLLOW_BORDER + NARROW_HSPACING;
-entry_out_y0  = y0 + 28;
-entry_text_y0 = entry_out_y0 + HOLLOW_BORDER + NARROW_VSPACING;
-entry_text_y1 = entry_text_y0 + FONTH - 1;
-entry_out_y1  = entry_text_y1 + HOLLOW_BORDER + NARROW_VSPACING;
+    entry_out_x0 = x0 + 10;
+    entry_text_x0 = entry_out_x0 + HOLLOW_BORDER + NARROW_HSPACING;
+    entry_text_x1 = entry_text_x0 + 10 * FONTW - 1;
+    entry_out_x1 = entry_text_x1 + HOLLOW_BORDER + NARROW_HSPACING;
+    entry_out_y0 = y0 + 28;
+    entry_text_y0 = entry_out_y0 + HOLLOW_BORDER + NARROW_VSPACING;
+    entry_text_y1 = entry_text_y0 + FONTH - 1;
+    entry_out_y1 = entry_text_y1 + HOLLOW_BORDER + NARROW_VSPACING;
 
-listdisp = y_max (listdisp,
-  (win_height - (entry_out_y0 - y0) - BOX_BORDER - WIDE_VSPACING) / FONTH);
+    listdisp = y_max(listdisp,
+		     (win_height - (entry_out_y0 - y0) - BOX_BORDER -
+		      WIDE_VSPACING) / FONTH);
 
 // Draw the dialog box
-DrawScreenBox3D (x0, y0, x0 + win_width, y0 + win_height);
-DrawScreenBoxHollow (entry_out_x0, entry_out_y0, entry_out_x1, entry_out_y1,
-		     BLACK);
-set_colour (WINTITLE);
-DrawScreenText (x0 + 10, y0 + 8, prompt);
-set_colour (WINFG);
-if (hookfunc != NULL)
-   {
-   DrawScreenText (x0 + 10,
-		   y0 + win_height - BOX_BORDER - WIDE_VSPACING - 2 * FONTH,
-		   msg1);
-   DrawScreenText (x0 + 10,
-		   y0 + win_height - BOX_BORDER - WIDE_VSPACING - FONTH,
-		   msg2);
-   }
-if (width > 0)
-   DrawScreenBoxHollow (x1 - 1, y1 - 1, x2 + 1, y2 + 1, BLACK);
-firstkey = true;
+    DrawScreenBox3D(x0, y0, x0 + win_width, y0 + win_height);
+    DrawScreenBoxHollow(entry_out_x0, entry_out_y0, entry_out_x1,
+			entry_out_y1, BLACK);
+    set_colour(WINTITLE);
+    DrawScreenText(x0 + 10, y0 + 8, prompt);
+    set_colour(WINFG);
+    if (hookfunc != NULL)
+    {
+	DrawScreenText(x0 + 10,
+		       y0 + win_height - BOX_BORDER - WIDE_VSPACING -
+		       2 * FONTH, msg1);
+	DrawScreenText(x0 + 10,
+		       y0 + win_height - BOX_BORDER - WIDE_VSPACING - FONTH,
+		       msg2);
+    }
+    if (width > 0)
+	DrawScreenBoxHollow(x1 - 1, y1 - 1, x2 + 1, y2 + 1, BLACK);
+    firstkey = true;
 
 // Another way of saying "nothing to rub out"
-int disp_x0 = (x2 + x1) / 2;
-int disp_y0 = (y2 + y1) / 2;
-int disp_x1 = disp_x0 - 1;
-int disp_y1 = disp_y0 - 1;
+    int disp_x0 = (x2 + x1) / 2;
+    int disp_y0 = (y2 + y1) / 2;
+    int disp_x1 = disp_x0 - 1;
+    int disp_y1 = disp_y0 - 1;
 
-int maxpatches = 0;
+    int maxpatches = 0;
 
 // The event loop
-for (;;)
-   {
-   hookfunc_comm_t c;
+    for (;;)
+    {
+	hookfunc_comm_t c;
 
-   // Reset maxpatches every time when change texture
-   if (strcmp (name, namedisp) != 0)
-     maxpatches = 0;
+	// Reset maxpatches every time when change texture
+	if (strcmp(name, namedisp) != 0)
+	    maxpatches = 0;
 
-   // Is "name" in the list ?
-   for (n = 0; n < listsize; n++)
-      if (y_stricmp (name, list[n]) <= 0)
-	 break;
-   ok = n < listsize ? ! y_stricmp (name, list[n]) : false;
-   if (n >= listsize)
-      n = listsize - 1;
+	// Is "name" in the list ?
+	for (n = 0; n < listsize; n++)
+	    if (y_stricmp(name, list[n]) <= 0)
+		break;
+	ok = n < listsize ? !y_stricmp(name, list[n]) : false;
+	if (n >= listsize)
+	    n = listsize - 1;
 
-   // Display the <listdisp> next items in the list
-   {
-   size_t l;				// Current line
-   int y = entry_out_y0;		// Y-coord of current line
-   int xmin = x0 + xlist;
-   int xmax = xmin + FONTW * maxlen - 1;
-   for (l = 0; l < listdisp && n + l < listsize; l++)
-      {
-      if (false && has_input_event ())	// TEST
-	 {
-	 putchar ('.');		// TEST
-	 fflush (stdout);	// TEST
-	 goto shortcut;		// TEST
-	 }
-      set_colour (WINBG);
-      DrawScreenBox (xmin, y, xmax, y + FONTH - 1);
-      set_colour (WINFG);
-      DrawScreenText (xmin, y, list[n+l]);
-      y += FONTH;
-      }
-   if (l < listdisp)  // Less than <listdisp> names to display
-      {
-      set_colour (WINBG);
-      DrawScreenBox (xmin, y, xmax, entry_out_y0 + listdisp * FONTH - 1);
-      }
-   }
+	// Display the <listdisp> next items in the list
+	{
+	    size_t l;		// Current line
+	    int y = entry_out_y0;	// Y-coord of current line
+	    int xmin = x0 + xlist;
+	    int xmax = xmin + FONTW * maxlen - 1;
+	    for (l = 0; l < listdisp && n + l < listsize; l++)
+	    {
+		if (false && has_input_event())	// TEST
+		{
+		    putchar('.');	// TEST
+		    fflush(stdout);	// TEST
+		    goto shortcut;	// TEST
+		}
+		set_colour(WINBG);
+		DrawScreenBox(xmin, y, xmax, y + FONTH - 1);
+		set_colour(WINFG);
+		DrawScreenText(xmin, y, list[n + l]);
+		y += FONTH;
+	    }
+	    if (l < listdisp)	// Less than <listdisp> names to display
+	    {
+		set_colour(WINBG);
+		DrawScreenBox(xmin, y, xmax,
+			      entry_out_y0 + listdisp * FONTH - 1);
+	    }
+	}
 
-   // Display the entry box and the current text
-   set_colour (BLACK);
-   DrawScreenBox (entry_text_x0, entry_text_y0, entry_text_x1, entry_text_y1);
-   if (ok)  // FIXME this colour scheme should be changed.
-      set_colour (WHITE);
-   else
-      set_colour (WINFG);
-   DrawScreenText (entry_text_x0, entry_text_y0, name);
+	// Display the entry box and the current text
+	set_colour(BLACK);
+	DrawScreenBox(entry_text_x0, entry_text_y0, entry_text_x1,
+		      entry_text_y1);
+	if (ok)			// FIXME this colour scheme should be changed.
+	    set_colour(WHITE);
+	else
+	    set_colour(WINFG);
+	DrawScreenText(entry_text_x0, entry_text_y0, name);
 
-   // Call the function to display the picture, if any
-   if (hookfunc)
-      {
-      // Display the picture name
-      c.x0         = x1;
-      c.y0         = y1;
-      c.x1         = x2;
-      c.y1         = y2;
-      c.name       = name;
-      c.xofs       = 0;
-      c.yofs       = 0;
-      c.flags      = flags_to_pass_to_callback;
-      const int BAD_VALUE = INT_MAX;
-      c.disp_x0    = BAD_VALUE;  // Catch faulty callbacks
-      c.disp_y0    = BAD_VALUE;  // Catch faulty callbacks
-      c.disp_x1    = BAD_VALUE;  // Catch faulty callbacks
-      c.disp_y1    = BAD_VALUE;  // Catch faulty callbacks
-      c.maxpatches = maxpatches;
-      if (ok)
-	 {
-	 hookfunc (&c);
-	 }
-      else
-	 {
-	 // No picture. Null width & height. Erase everything.
-	 c.disp_x0 = (x2 + x1) / 2;
-	 c.disp_y0 = (y2 + y1) / 2;
-	 c.disp_x1 = c.disp_x0 - 1;
-	 c.disp_y1 = c.disp_y0 - 1;
-	 }
-      strcpy (namedisp, name);
+	// Call the function to display the picture, if any
+	if (hookfunc)
+	{
+	    // Display the picture name
+	    c.x0 = x1;
+	    c.y0 = y1;
+	    c.x1 = x2;
+	    c.y1 = y2;
+	    c.name = name;
+	    c.xofs = 0;
+	    c.yofs = 0;
+	    c.flags = flags_to_pass_to_callback;
+	    const int BAD_VALUE = INT_MAX;
+	    c.disp_x0 = BAD_VALUE;	// Catch faulty callbacks
+	    c.disp_y0 = BAD_VALUE;	// Catch faulty callbacks
+	    c.disp_x1 = BAD_VALUE;	// Catch faulty callbacks
+	    c.disp_y1 = BAD_VALUE;	// Catch faulty callbacks
+	    c.maxpatches = maxpatches;
+	    if (ok)
+	    {
+		hookfunc(&c);
+	    }
+	    else
+	    {
+		// No picture. Null width & height. Erase everything.
+		c.disp_x0 = (x2 + x1) / 2;
+		c.disp_y0 = (y2 + y1) / 2;
+		c.disp_x1 = c.disp_x0 - 1;
+		c.disp_y1 = c.disp_y0 - 1;
+	    }
+	    strcpy(namedisp, name);
 
-      // Display the (unclipped) size of the picture
-      {
-      const size_t size_chars = 11;
-      const int    size_x0    = x0 + 10;
-      const int    size_y0    = y0 + 50;
-      if (picture_size_drawn)
-	 {
-	 set_colour (WINBG);
-	 DrawScreenBoxwh (size_x0, size_y0, size_chars * FONTW, FONTH);
-	 picture_size_drawn = false;
-	 }
-      if ((c.flags & HOOK_SIZE_VALID) && (c.flags & HOOK_DISP_SIZE))
-	 {
-	 set_colour (WINFG);
-	 char size_buf[100];  // Slack
-	 y_snprintf (size_buf, sizeof size_buf, "%dx%d", c.width, c.height);
-	 if (strlen (size_buf) > size_chars)
-	   strcpy (size_buf + size_chars - 1, ">");
-	 DrawScreenString (size_x0, size_y0, size_buf);
-	 picture_size_drawn = true;
-	 }
-      }
+	    // Display the (unclipped) size of the picture
+	    {
+		const size_t size_chars = 11;
+		const int size_x0 = x0 + 10;
+		const int size_y0 = y0 + 50;
+		if (picture_size_drawn)
+		{
+		    set_colour(WINBG);
+		    DrawScreenBoxwh(size_x0, size_y0, size_chars * FONTW,
+				    FONTH);
+		    picture_size_drawn = false;
+		}
+		if ((c.flags & HOOK_SIZE_VALID) && (c.flags & HOOK_DISP_SIZE))
+		{
+		    set_colour(WINFG);
+		    char size_buf[100];	// Slack
+		    y_snprintf(size_buf, sizeof size_buf, "%dx%d", c.width,
+			       c.height);
+		    if (strlen(size_buf) > size_chars)
+			strcpy(size_buf + size_chars - 1, ">");
+		    DrawScreenString(size_x0, size_y0, size_buf);
+		    picture_size_drawn = true;
+		}
+	    }
 
 #ifdef DEBUG
-      // Display the file name and file offset of the picture
-      {
-      const size_t loc_chars = win_width / FONTW;
-      const int    loc_x0    = x0;
-      const int    loc_y0    = y0 + win_height;
-      if (lump_loc_drawn)
-	 {
-	 set_colour (WINBG);
-	 DrawScreenBoxwh (loc_x0, loc_y0, loc_chars * FONTW, FONTH);
-	 lump_loc_drawn = false;
-	 }
-      if (disp_lump_loc && (c.flags & HOOK_LOC_VALID))
-	 {
-	 set_colour (WINFG);
-	 char buf[150];  // Slack
-	 lump_loc_string (buf, sizeof buf, c.lump_loc);
-	 DrawScreenString (loc_x0, loc_y0, buf);
-	 lump_loc_drawn = true;
-	 }
-      }
+	    // Display the file name and file offset of the picture
+	    {
+		const size_t loc_chars = win_width / FONTW;
+		const int loc_x0 = x0;
+		const int loc_y0 = y0 + win_height;
+		if (lump_loc_drawn)
+		{
+		    set_colour(WINBG);
+		    DrawScreenBoxwh(loc_x0, loc_y0, loc_chars * FONTW, FONTH);
+		    lump_loc_drawn = false;
+		}
+		if (disp_lump_loc && (c.flags & HOOK_LOC_VALID))
+		{
+		    set_colour(WINFG);
+		    char buf[150];	// Slack
+		    lump_loc_string(buf, sizeof buf, c.lump_loc);
+		    DrawScreenString(loc_x0, loc_y0, buf);
+		    lump_loc_drawn = true;
+		}
+	    }
 #endif
 
-      /* If the new picture does not completely obscure the
-	 previous one, rub out the old pixels. */
-      set_colour (BLACK);
-      if (c.disp_x0 == BAD_VALUE
-	|| c.disp_y0 == BAD_VALUE
-	|| c.disp_x1 == BAD_VALUE
-	|| c.disp_y1 == BAD_VALUE)
-	 nf_bug ("Callback %p did not set disp_", hookfunc);
-      else
-	 {
-	 /* +-WINDOW------------------------+   Erase the dots...
-            |                               |
-	    |  +-OLD IMAGE---------------+  |   (this is for the case where
-	    |  | . . : . . . . . . : . . |  |   the image is centred but the
-	    |  |. . .:. . . 3 . . .:. . .|  |   principle is the same if it's
-	    |  | . . : . . . . . . : . . |  |   E.G. in the top left corner)
-	    |  |. . .+-NEW IMAGE---+. . .|  |
-	    |  | . . |             | . . |  |
-	    |  |. 1 .|             |. 2 .|  |
-	    |  | . . |             | . . |  |
-	    |  |. . .+-------------+. . .|  |
-	    |  | . . : . . . . . . : . . |  |
-	    |  |. . .:. . . 4 . . .:. . .|  |
-	    |  | . . : . . . . . . : . . |  |
-	    |  +-------------------------+  |
-	    |                               |
-	    +-------------------------------+ */
-	 if (c.disp_x0 > disp_x0)
-	    DrawScreenBox (disp_x0, disp_y0, c.disp_x0 - 1, disp_y1);  // (1)
-	 if (c.disp_x1 < disp_x1)
-	    DrawScreenBox (c.disp_x1 + 1, disp_y0, disp_x1, disp_y1);  // (2)
-	 if (c.disp_y0 > disp_y0)
-	    DrawScreenBox (y_max (c.disp_x0, disp_x0), disp_y0,
-			   y_min (c.disp_x1, disp_x1), c.disp_y0 - 1); // (3)
-	 if (c.disp_y1 < disp_y1)
-	    DrawScreenBox (y_max (c.disp_x0, disp_x0), c.disp_y1 + 1,
-			   y_min (c.disp_x1, disp_x1), disp_y1);       // (4)
-	 }
-      disp_x0 = c.disp_x0;
-      disp_y0 = c.disp_y0;
-      disp_x1 = c.disp_x1;
-      disp_y1 = c.disp_y1;
-      }
+	    /* If the new picture does not completely obscure the
+	       previous one, rub out the old pixels. */
+	    set_colour(BLACK);
+	    if (c.disp_x0 == BAD_VALUE
+		|| c.disp_y0 == BAD_VALUE
+		|| c.disp_x1 == BAD_VALUE || c.disp_y1 == BAD_VALUE)
+		nf_bug("Callback %p did not set disp_", hookfunc);
+	    else
+	    {
+		/* +-WINDOW------------------------+   Erase the dots...
+		   |                               |
+		   |  +-OLD IMAGE---------------+  |   (this is for the case where
+		   |  | . . : . . . . . . : . . |  |   the image is centred but the
+		   |  |. . .:. . . 3 . . .:. . .|  |   principle is the same if it's
+		   |  | . . : . . . . . . : . . |  |   E.G. in the top left corner)
+		   |  |. . .+-NEW IMAGE---+. . .|  |
+		   |  | . . |             | . . |  |
+		   |  |. 1 .|             |. 2 .|  |
+		   |  | . . |             | . . |  |
+		   |  |. . .+-------------+. . .|  |
+		   |  | . . : . . . . . . : . . |  |
+		   |  |. . .:. . . 4 . . .:. . .|  |
+		   |  | . . : . . . . . . : . . |  |
+		   |  +-------------------------+  |
+		   |                               |
+		   +-------------------------------+ */
+		if (c.disp_x0 > disp_x0)
+		    DrawScreenBox(disp_x0, disp_y0, c.disp_x0 - 1, disp_y1);	// (1)
+		if (c.disp_x1 < disp_x1)
+		    DrawScreenBox(c.disp_x1 + 1, disp_y0, disp_x1, disp_y1);	// (2)
+		if (c.disp_y0 > disp_y0)
+		    DrawScreenBox(y_max(c.disp_x0, disp_x0), disp_y0, y_min(c.disp_x1, disp_x1), c.disp_y0 - 1);	// (3)
+		if (c.disp_y1 < disp_y1)
+		    DrawScreenBox(y_max(c.disp_x0, disp_x0), c.disp_y1 + 1, y_min(c.disp_x1, disp_x1), disp_y1);	// (4)
+	    }
+	    disp_x0 = c.disp_x0;
+	    disp_y0 = c.disp_y0;
+	    disp_x1 = c.disp_x1;
+	    disp_y1 = c.disp_y1;
+	}
 
-   // Process user input
-shortcut:
-   key = get_key ();
-   if (firstkey && is_ordinary (key) && key != ' ')
-      {
-      for (size_t i = 0; i <= maxlen; i++)
-	 name[i] = '\0';
-      }
-   firstkey = false;
-   size_t len = strlen (name);
-   if (len < maxlen && key >= 'a' && key <= 'z')
-      {
-      name[len] = key + 'A' - 'a';
-      name[len + 1] = '\0';
-      }
-   else if (len < maxlen && is_ordinary (key) && key != ' ')
-      {
-      name[len] = key;
-      name[len + 1] = '\0';
-      }
-   else if (len > 0 && key == YK_BACKSPACE)		// BS
-      name[len - 1] = '\0';
-   else if (key == 21 || key == 23)			// ^U, ^W
-      *name = '\0';
-   else if (key == YK_DOWN)				// [Down]
-      {
-      /* Look for the next item in the list that has a
-	 different name. Why not just use the next item ?
-	 Because sometimes the list has duplicates (for example
-	 when editing a Doom II pwad in Doom mode) and then the
-	 viewer gets "stuck" on the first duplicate. */
-      size_t m = n + 1;
-      while (m < listsize && ! y_stricmp (list[n], list[m]))
-	 m++;
-      if (m < listsize)
-         strcpy (name, list[m]);
-      else
-	 Beep ();
-      }
-   else if (key == YK_UP)				// [Up]
-      {
-      // Same trick as for [Down]
-      int m = n - 1;
-      while (m >= 0 && ! y_stricmp (list[n], list[m]))
-	 m--;
-      if (m >= 0)
-         strcpy (name, list[m]);
-      else
-         Beep ();
-      }
-   else if (key == YK_PD || key == 6 || key == 22)	// [Pgdn], ^F, ^V
-      { 
-      if (n < listsize - listdisp)
-         strcpy (name, list[y_min (n + listdisp, listsize - 1)]);
-      else
-	 Beep ();
-      }
-   else if ((key == YK_PU || key == 2) && n > 0)	// [Pgup], ^B
-      {
-      if (n > listdisp)
-	 strcpy (name, list[n - listdisp]);
-      else
-	 strcpy (name, list[0]);
-      }
-   else if (key == 14)					// ^N
-      {
-      if (n + 1 >= listsize)
-	 {
-	 Beep ();
-         goto done_with_event;
-	 }
-      while (n + 1 < listsize)
-	 {
-	 n++;
-	 if (y_strnicmp (list[n - 1], list[n], 4))
+	// Process user input
+      shortcut:
+	key = get_key();
+	if (firstkey && is_ordinary(key) && key != ' ')
+	{
+	    for (size_t i = 0; i <= maxlen; i++)
+		name[i] = '\0';
+	}
+	firstkey = false;
+	size_t len = strlen(name);
+	if (len < maxlen && key >= 'a' && key <= 'z')
+	{
+	    name[len] = key + 'A' - 'a';
+	    name[len + 1] = '\0';
+	}
+	else if (len < maxlen && is_ordinary(key) && key != ' ')
+	{
+	    name[len] = key;
+	    name[len + 1] = '\0';
+	}
+	else if (len > 0 && key == YK_BACKSPACE)	// BS
+	    name[len - 1] = '\0';
+	else if (key == 21 || key == 23)	// ^U, ^W
+	    *name = '\0';
+	else if (key == YK_DOWN)	// [Down]
+	{
+	    /* Look for the next item in the list that has a
+	       different name. Why not just use the next item ?
+	       Because sometimes the list has duplicates (for example
+	       when editing a Doom II pwad in Doom mode) and then the
+	       viewer gets "stuck" on the first duplicate. */
+	    size_t m = n + 1;
+	    while (m < listsize && !y_stricmp(list[n], list[m]))
+		m++;
+	    if (m < listsize)
+		strcpy(name, list[m]);
+	    else
+		Beep();
+	}
+	else if (key == YK_UP)	// [Up]
+	{
+	    // Same trick as for [Down]
+	    int m = n - 1;
+	    while (m >= 0 && !y_stricmp(list[n], list[m]))
+		m--;
+	    if (m >= 0)
+		strcpy(name, list[m]);
+	    else
+		Beep();
+	}
+	else if (key == YK_PD || key == 6 || key == 22)	// [Pgdn], ^F, ^V
+	{
+	    if (n < listsize - listdisp)
+		strcpy(name, list[y_min(n + listdisp, listsize - 1)]);
+	    else
+		Beep();
+	}
+	else if ((key == YK_PU || key == 2) && n > 0)	// [Pgup], ^B
+	{
+	    if (n > listdisp)
+		strcpy(name, list[n - listdisp]);
+	    else
+		strcpy(name, list[0]);
+	}
+	else if (key == 14)	// ^N
+	{
+	    if (n + 1 >= listsize)
+	    {
+		Beep();
+		goto done_with_event;
+	    }
+	    while (n + 1 < listsize)
+	    {
+		n++;
+		if (y_strnicmp(list[n - 1], list[n], 4))
+		    break;
+	    }
+	    strcpy(name, list[n]);
+	}
+	else if (key == 16)	// ^P
+	{
+	    if (n < 1)
+	    {
+		Beep();
+		goto done_with_event;
+	    }
+	    // Put in <n> the index of the first entry of the current
+	    // group or, if already at the beginning of the current
+	    // group, the first entry of the previous group.
+	    if (n > 0)
+	    {
+		if (y_strnicmp(list[n], list[n - 1], 4))
+		    n--;
+		while (n > 0 && !y_strnicmp(list[n], list[n - 1], 4))
+		    n--;
+	    }
+	    strcpy(name, list[n]);
+	}
+	else if (key == (YK_CTRL | YK_PD) || key == YK_END)	// [Ctrl][Pgdn], [End]
+	{
+	    if (n + 1 >= listsize)
+	    {
+		Beep();
+		goto done_with_event;
+	    }
+	    strcpy(name, list[listsize - 1]);
+	}
+	else if (key == (YK_CTRL | YK_PU) || key == YK_HOME)	// [Ctrl][Pgup], [Home]
+	{
+	    if (n < 1)
+	    {
+		Beep();
+		goto done_with_event;
+	    }
+	    strcpy(name, list[0]);
+	}
+	else if (key == YK_TAB)	// [Tab]
+	    strcpy(name, list[n]);
+	else if (key == YK_F1 && c.flags & HOOK_LOC_VALID)	// [F1]: print location
+	{
+	    printf("%.8s: %s(%08lXh)\n",
+		   name, c.lump_loc.wad->pathname(),
+		   (unsigned long) c.lump_loc.ofs);
+	}
+	else if (key == YK_F1 + YK_SHIFT	// [Shift][F1] : dump image to file
+		 && hookfunc != NULL && (c.flags & HOOK_DRAWN))
+	{
+	    const size_t size = strlen(name) + 4 + 1;
+	    char *filename = new char[size];
+	    al_scpslower(filename, name, size - 1);
+	    al_saps(filename, ".ppm", size - 1);
+	    if (c.img.save(filename) != 0)
+	    {
+		if (errno == ECHILD)
+		    err("Error loading PLAYPAL");
+		else
+		    err("%s: %s", filename, strerror(errno));
+	    }
+	    else
+	    {
+		printf("Saved %s as %s\n", name, filename);
+	    }
+	    delete[]filename;
+	}
+	else if (key == 1)	// ^A: more patches
+	{
+	    if (maxpatches + 1 < c.npatches)
+		maxpatches++;
+	    else
+		maxpatches = 0;
+	    printf("maxpatches %d\n", maxpatches);
+	}
+	else if (key == 24)	// ^X: less patches
+	{
+	    if (maxpatches == 0)
+		maxpatches = c.npatches - 1;
+	    else
+		maxpatches--;
+	    printf("maxpatches %d\n", maxpatches);
+	}
+	else if (ok && key == YK_RETURN)	// [Return]
+	    break;		/* return "name" */
+	else if (key == YK_ESC)	// [Esc]
+	{
+	    name[0] = '\0';	/* return an empty string */
 	    break;
-	 }
-      strcpy (name, list[n]);
-      }
-   else if (key == 16)					// ^P
-      {
-      if (n < 1)
-	 {
-	 Beep ();
-	 goto done_with_event;
-	 }
-      // Put in <n> the index of the first entry of the current
-      // group or, if already at the beginning of the current
-      // group, the first entry of the previous group.
-      if (n > 0)
-	 {
-	 if (y_strnicmp (list[n], list[n - 1], 4))
-	    n--;
-	 while (n > 0 && ! y_strnicmp (list[n], list[n - 1], 4))
-	    n--;
-	 }
-      strcpy (name, list[n]);
-      }
-   else if (key == (YK_CTRL | YK_PD) || key == YK_END)	// [Ctrl][Pgdn], [End]
-      {
-      if (n + 1 >= listsize)
-	 {
-	 Beep ();
-	 goto done_with_event;
-	 }
-      strcpy (name, list[listsize - 1]);
-      }
-   else if (key == (YK_CTRL | YK_PU) || key == YK_HOME)	// [Ctrl][Pgup], [Home]
-      {
-      if (n < 1)
-	 {
-	 Beep ();
-	 goto done_with_event;
-	 }
-      strcpy (name, list[0]);
-      }
-   else if (key == YK_TAB)				// [Tab]
-      strcpy (name, list[n]);
-   else if (key == YK_F1 && c.flags & HOOK_LOC_VALID)	// [F1]: print location
-      {
-      printf ("%.8s: %s(%08lXh)\n",
-	 name, c.lump_loc.wad->pathname (), (unsigned long) c.lump_loc.ofs);
-      }
-   else if (key == YK_F1 + YK_SHIFT	// [Shift][F1] : dump image to file
-    && hookfunc != NULL
-    && (c.flags & HOOK_DRAWN))
-      {
-      const size_t size = strlen (name) + 4 + 1;
-      char *filename = new char[size];
-      al_scpslower (filename, name,   size - 1);
-      al_saps      (filename, ".ppm", size - 1);
-      if (c.img.save (filename) != 0)
-	 {
-	 if (errno == ECHILD)
-	    err ("Error loading PLAYPAL");
-	 else
-	    err ("%s: %s", filename, strerror (errno));
-	 }
-      else
-	 {
-	 printf ("Saved %s as %s\n", name, filename);
-	 }
-      delete[] filename;
-      }
-   else if (key == 1)					// ^A: more patches
-      {
-      if (maxpatches + 1 < c.npatches)
-	maxpatches++;
-      else
-	maxpatches = 0;
-      printf ("maxpatches %d\n", maxpatches);
-      }
-   else if (key == 24)					// ^X: less patches
-      {
-      if (maxpatches == 0)
-	maxpatches = c.npatches - 1;
-      else
-	maxpatches--;
-      printf ("maxpatches %d\n", maxpatches);
-      }
-   else if (ok && key == YK_RETURN)			// [Return]
-      break; /* return "name" */
-   else if (key == YK_ESC)				// [Esc]
-      {
-      name[0] = '\0'; /* return an empty string */
-      break;
-      }
-   else
-      Beep ();
-done_with_event:
-   ;
-   }
-delete[] namedisp;
+	}
+	else
+	    Beep();
+      done_with_event:
+	;
+    }
+    delete[]namedisp;
 }
 
 
@@ -565,17 +566,11 @@
    ask for a name in a given list
 */
 
-void InputNameFromList (
-   int x0,
-   int y0,
-   const char *prompt,
-   size_t listsize,
-   const char *const *list,
-   char *name)
+void InputNameFromList(int x0,
+		       int y0,
+		       const char *prompt,
+		       size_t listsize, const char *const *list, char *name)
 {
-InputNameFromListWithFunc (x0, y0, prompt, listsize, list, 5, name, 0, 0, NULL);
+    InputNameFromListWithFunc(x0, y0, prompt, listsize, list, 5, name, 0, 0,
+			      NULL);
 }
-
-
-
-
--- a/src/lists.h	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/lists.h	Sat Sep 24 14:16:04 2011 +0300
@@ -27,7 +27,7 @@
 */
 
 
-#ifndef YH_LISTS  /* DO NOT INSERT ANYTHING BEFORE THIS LINE */
+#ifndef YH_LISTS		/* DO NOT INSERT ANYTHING BEFORE THIS LINE */
 #define YH_LISTS
 
 #include "img.h"
@@ -74,41 +74,41 @@
 */
 typedef struct
 {
-  int x0;           // [expected] Top left corner of where to draw image
-  int y0;
-  int x1;           // [expected] Bottom right corner
-  int y1;
-  int disp_x0;      // [returned] Top left corner and bottom right corner
-  int disp_y0;      // of area that was drawn on by callee. This is so that
-  int disp_x1;      // the caller knows what needs to be cleared...
-  int disp_y1;
-  int xofs;         // [expected] Top left corner of image in buffer
-  int yofs;
-  const char *name; // [expected] Name of image to display
-  int flags;        // [both]     Flags
-  Img img;          // [returned] Image buffer (clipped !)
-  int width;        // [returned] Width of image before clipping
-  int height;       // [returned] Height of image before clipping
-  int npatches;     // [returned] Textures only : number of patches
-  int maxpatches;   // [expected] Textures: if !0 only render that many patches
-  Lump_loc lump_loc;// [returned] Location of lump that was just displayed
+    int x0;			// [expected] Top left corner of where to draw image
+    int y0;
+    int x1;			// [expected] Bottom right corner
+    int y1;
+    int disp_x0;		// [returned] Top left corner and bottom right corner
+    int disp_y0;		// of area that was drawn on by callee. This is so that
+    int disp_x1;		// the caller knows what needs to be cleared...
+    int disp_y1;
+    int xofs;			// [expected] Top left corner of image in buffer
+    int yofs;
+    const char *name;		// [expected] Name of image to display
+    int flags;			// [both]     Flags
+    Img img;			// [returned] Image buffer (clipped !)
+    int width;			// [returned] Width of image before clipping
+    int height;			// [returned] Height of image before clipping
+    int npatches;		// [returned] Textures only : number of patches
+    int maxpatches;		// [expected] Textures: if !0 only render that many patches
+    Lump_loc lump_loc;		// [returned] Location of lump that was just displayed
 } hookfunc_comm_t;
-const int HOOK_DRAWN      = 1 << 0;	// Image is completely drawn
+const int HOOK_DRAWN = 1 << 0;	// Image is completely drawn
 const int HOOK_SIZE_VALID = 1 << 1;	// width and height are valid
-const int HOOK_DISP_SIZE  = 1 << 2;	// Caller should display "widthxheight"
-const int HOOK_SPECTRAL   = 1 << 3;	// Render picture with a spectral look
-const int HOOK_PATCH      = 1 << 4;	// Use patch_dir.loc_by_name()
-const int HOOK_SPRITE     = 1 << 5;	// Use wad_res.sprites.loc_by_name()
-const int HOOK_LOC_VALID  = 1 << 6;	// lump_loc is valid
-const int HOOK_ROOT       = 1 << 7;	// .name is the prefix. Use loc_by_root
+const int HOOK_DISP_SIZE = 1 << 2;	// Caller should display "widthxheight"
+const int HOOK_SPECTRAL = 1 << 3;	// Render picture with a spectral look
+const int HOOK_PATCH = 1 << 4;	// Use patch_dir.loc_by_name()
+const int HOOK_SPRITE = 1 << 5;	// Use wad_res.sprites.loc_by_name()
+const int HOOK_LOC_VALID = 1 << 6;	// lump_loc is valid
+const int HOOK_ROOT = 1 << 7;	// .name is the prefix. Use loc_by_root
 
 
-void InputNameFromListWithFunc (int, int, const char *, size_t,
-  const char *const *, size_t, char *, int, int,
-  void (*hookfunc)(hookfunc_comm_t *),
-  char flags_to_pass_to_callback = 0);
-void InputNameFromList (int, int, const char *, size_t, const char *const *,
-  char *);
+void InputNameFromListWithFunc(int, int, const char *, size_t,
+			       const char *const *, size_t, char *, int, int,
+			       void (*hookfunc) (hookfunc_comm_t *),
+			       char flags_to_pass_to_callback = 0);
+void InputNameFromList(int, int, const char *, size_t, const char *const *,
+		       char *);
 
 
-#endif  /* DO NOT ADD ANYTHING AFTER THIS LINE */
+#endif /* DO NOT ADD ANYTHING AFTER THIS LINE */
--- a/src/locate.cc	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/locate.cc	Sat Sep 24 14:16:04 2011 +0300
@@ -48,14 +48,14 @@
  *	- backwards is the direction in which the search path is
  *	  walked. true is front-to-back, false is back-to-front.
  */
-Locate::Locate (const char *const *search_path, const char *name, bool backw)
+Locate::Locate(const char *const *search_path, const char *name, bool backw)
 {
-  this->search_path = search_path;
-  this->name        = name;
-  this->backwards   = backw;
-  absolute          = is_absolute (name);
-  rewound           = true;
-  rewind ();
+    this->search_path = search_path;
+    this->name = name;
+    this->backwards = backw;
+    absolute = is_absolute(name);
+    rewound = true;
+    rewind();
 }
 
 
@@ -66,20 +66,20 @@
  *	get_next() to return the first match, as if get_next()
  *	had never been called.
  */
-void Locate::rewind ()
+void Locate::rewind()
 {
-  rewound = true;
+    rewound = true;
 
-  if (backwards)
-  {
-    // Advance to the end of the list
-    for (cursor = search_path; *cursor != NULL; cursor++)
-      ;
-  }
-  else
-  {
-    cursor = search_path;
-  }
+    if (backwards)
+    {
+	// Advance to the end of the list
+	for (cursor = search_path; *cursor != NULL; cursor++)
+	    ;
+    }
+    else
+    {
+	cursor = search_path;
+    }
 }
 
 
@@ -91,93 +91,92 @@
  *	returned pointer is valid until get_next() is called
  *	again or the Locate object is destroyed.
  */
-const char *Locate::get_next ()
+const char *Locate::get_next()
 {
-  if (absolute)
-  {
-    if (! rewound)			// Result has exactly one element
-      return NULL;
-    rewound = false;
-    if (strlen (name) > sizeof pathname - 1)
+    if (absolute)
     {
-      warn ("%s: file name too long\n", name);
-      return NULL;
-    }
-    strcpy (pathname, name);
-    return pathname;
-  }
-
-  const char *home = getenv ("HOME");
-
-  // Walk the list
-  for (;;)
-  {
-    // Make dirname point to the current path in the search path
-    const char *dirname;
-
-    if (backwards)
-    {
-      if (cursor == search_path)
-	break;
-      cursor--;
-      dirname = *cursor;
-    }
-    else
-    {
-      if (*cursor == NULL)
-	break;
-      dirname = *cursor;
-      cursor++;
+	if (!rewound)		// Result has exactly one element
+	    return NULL;
+	rewound = false;
+	if (strlen(name) > sizeof pathname - 1)
+	{
+	    warn("%s: file name too long\n", name);
+	    return NULL;
+	}
+	strcpy(pathname, name);
+	return pathname;
     }
 
-    // Expand the macros in the path into the result buffer
-    int r = macro_expand (pathname, sizeof pathname - 1, dirname,
-      "%i", install_dir,
-      "%v", yadex_version,
-      "~",  home,
-      (const char *) 0);
-    if (r != 0)
+    const char *home = getenv("HOME");
+
+    // Walk the list
+    for (;;)
     {
-      trace ("locate", "%s: Could not expand macro #%d", dirname, r);
-      continue;
+	// Make dirname point to the current path in the search path
+	const char *dirname;
+
+	if (backwards)
+	{
+	    if (cursor == search_path)
+		break;
+	    cursor--;
+	    dirname = *cursor;
+	}
+	else
+	{
+	    if (*cursor == NULL)
+		break;
+	    dirname = *cursor;
+	    cursor++;
+	}
+
+	// Expand the macros in the path into the result buffer
+	int r = macro_expand(pathname, sizeof pathname - 1, dirname,
+			     "%i", install_dir,
+			     "%v", yadex_version,
+			     "~", home,
+			     (const char *) 0);
+	if (r != 0)
+	{
+	    trace("locate", "%s: Could not expand macro #%d", dirname, r);
+	    continue;
+	}
+
+	// Append the basename
+	if (strlen(pathname) > 0 && pathname[strlen(pathname)] - 1 != '/')
+	{
+	    if (strlen(pathname) + 2 >= sizeof pathname)
+	    {
+		warn("%s: file name too long, skipping\n", dirname);
+		continue;
+	    }
+	    strcat(pathname, "/");
+	}
+	if (strlen(pathname) + strlen(name) + 1 >= sizeof pathname)
+	{
+	    warn("%s: file name too long, skipping\n", dirname);
+	    continue;
+	}
+	strcat(pathname, name);
+
+	// Look for a file of that name.
+	struct stat s;
+	r = stat(pathname, &s);
+	if (r == 0 && !S_ISDIR(s.st_mode))
+	{
+	    trace("locate", "%s: %s: hit", name, pathname);
+	    return pathname;
+	}
+	else if (r == 0 && S_ISDIR(s.st_mode))
+	{
+	    errno = EISDIR;
+	}
+	else if (r != 0 && errno != ENOENT)
+	{
+	    warn("%s: %s\n", pathname, strerror(errno));
+	}
+	trace("locate", "%s: %s: miss (%s)", name, pathname, strerror(errno));
     }
 
-    // Append the basename
-    if (strlen (pathname) > 0 && pathname[strlen (pathname)] - 1 != '/')
-    {
-      if (strlen (pathname) + 2 >= sizeof pathname)
-      {
-	warn ("%s: file name too long, skipping\n", dirname);
-	continue;
-      }
-      strcat (pathname, "/");
-    }
-    if (strlen (pathname) + strlen (name) + 1 >= sizeof pathname)
-    {
-      warn ("%s: file name too long, skipping\n", dirname);
-      continue;
-    }
-    strcat (pathname, name);
-
-    // Look for a file of that name.
-    struct stat s;
-    r = stat (pathname, &s);
-    if (r == 0 && ! S_ISDIR (s.st_mode))
-    {
-      trace ("locate", "%s: %s: hit", name, pathname);
-      return pathname;
-    }
-    else if (r == 0 && S_ISDIR (s.st_mode))
-    {
-      errno = EISDIR;
-    }
-    else if (r != 0 && errno != ENOENT)
-    {
-      warn ("%s: %s\n", pathname, strerror (errno));
-    }
-    trace ("locate", "%s: %s: miss (%s)", name, pathname, strerror (errno));
-  }
-
-  return NULL;
+    return NULL;
 }
-
--- a/src/locate.h	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/locate.h	Sat Sep 24 14:16:04 2011 +0300
@@ -20,26 +20,25 @@
 */
 
 
-#ifndef YH_LOCATE  /* DO NOT INSERT ANYTHING BEFORE THIS LINE */
+#ifndef YH_LOCATE		/* DO NOT INSERT ANYTHING BEFORE THIS LINE */
 #define YH_LOCATE
 
 
 class Locate
 {
-  public :
-    Locate (const char *const *search_path, const char *name, bool backwards);
-    void rewind ();
-    const char *get_next ();
+    public:Locate(const char *const *search_path, const char *name,
+		  bool backwards);
+    void rewind();
+    const char *get_next();
 
-  private :
-    const char *const *search_path;
-    const char        *name;
-    bool               absolute;
-    bool               backwards;
+      private: const char *const *search_path;
+    const char *name;
+    bool absolute;
+    bool backwards;
     const char *const *cursor;
-    bool               rewound;
-    char               pathname[1025];
+    bool rewound;
+    char pathname[1025];
 };
 
 
-#endif  /* DO NOT ADD ANYTHING AFTER THIS LINE */
+#endif /* DO NOT ADD ANYTHING AFTER THIS LINE */
--- a/src/lumpdir.cc	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/lumpdir.cc	Sat Sep 24 14:16:04 2011 +0300
@@ -47,24 +47,24 @@
  *	directory.
  */
 
-Lump_dir::Lump_dir (MDirPtr *md, char l, Serial_num *sn)
+Lump_dir::Lump_dir(MDirPtr * md, char l, Serial_num * sn)
 {
-  have_prev  = false;
-  dependency = new Dependency (sn);
-  master_dir = md;
-  label      = l;
+    have_prev = false;
+    dependency = new Dependency(sn);
+    master_dir = md;
+    label = l;
 }
 
 
 /*
  *	Lump_dir::~Lump_dir - dtor
  */
-Lump_dir::~Lump_dir ()
+Lump_dir::~Lump_dir()
 {
-  if (dependency)
-    delete dependency;
-  if (! lump_map.empty ())
-    lump_map.clear ();
+    if (dependency)
+	delete dependency;
+    if (!lump_map.empty())
+	lump_map.clear();
 }
 
 
@@ -74,25 +74,25 @@
  *	Return the (wad, offset, length) location of the lump
  *	named <name>. If not found, set loc.wad to 0.
  */
-void Lump_dir::loc_by_name (const char *name, Lump_loc& loc)
+void Lump_dir::loc_by_name(const char *name, Lump_loc & loc)
 {
-  if (dependency->outdated ())
-    refresh ();
+    if (dependency->outdated())
+	refresh();
 
-  /* Caller asked for same lump twice in a row. Save us a second
-     search. */
-  if (have_prev && ! y_strnicmp (name, name_prev, WAD_NAME))
-  {
-    loc = loc_prev;
-    return;
-  }
+    /* Caller asked for same lump twice in a row. Save us a second
+       search. */
+    if (have_prev && !y_strnicmp(name, name_prev, WAD_NAME))
+    {
+	loc = loc_prev;
+	return;
+    }
 
-  Lump_map::const_iterator i = lump_map.find (name);
-  have_prev = true;
-  if (i == lump_map.end ())
-    loc.wad = loc_prev.wad = 0;
-  else
-    loc = loc_prev = i->second;
+    Lump_map::const_iterator i = lump_map.find(name);
+    have_prev = true;
+    if (i == lump_map.end())
+	loc.wad = loc_prev.wad = 0;
+    else
+	loc = loc_prev = i->second;
 }
 
 
@@ -102,11 +102,11 @@
  *	Put a list of all lumps in the list, sorted by name and
  *	with duplicates removed, in <l>.
  */
-void Lump_dir::list (Lump_list& l)
+void Lump_dir::list(Lump_list & l)
 {
-  if (dependency->outdated ())
-    refresh ();
-  l.set (lump_map);
+    if (dependency->outdated())
+	refresh();
+    l.set(lump_map);
 }
 
 
@@ -116,146 +116,143 @@
  *	This is called automatically if the master directory has
  *	changed since the last refresh.
  */
-void Lump_dir::refresh ()
+void Lump_dir::refresh()
 {
-  /* refresh() can be called more than once one the same object.
-     And usually is ! */
-  have_prev = false;
-  if (! lump_map.empty ())
-    lump_map.clear ();
+    /* refresh() can be called more than once one the same object.
+       And usually is ! */
+    have_prev = false;
+    if (!lump_map.empty())
+	lump_map.clear();
 
-  /* Get list of lumps in the master directory. Everything
-     that is between X_START/X_END or XX_START/XX_END and that
-     is not a label is supposed to be added to the Lump_dir. */
-  Wad_name_c x_start  ("%c_START",   label);
-  Wad_name_c x_end    ("%c_END",     label);
-  Wad_name_c xx_start ("%c%c_START", label, label);
-  Wad_name_c xx_end   ("%c%c_END",   label, label);
-  for (MDirPtr dir = *master_dir;
-      dir && (dir = FindMasterDir (dir, x_start.name, xx_start.name));)
-  {
-    MDirPtr start_label = dir;
-    const char *end_label = 0;
-    if (! x_start.cmp (dir->dir.name))
-      end_label = x_end.name;
-    else if (! xx_start.cmp (dir->dir.name))
-      end_label = xx_end.name;
-    else
-      fatal_error ("Bad start label \"%.*s\"", (int) WAD_NAME, dir->dir.name);
-    dir = dir->next;
-    for (;; dir = dir->next)
+    /* Get list of lumps in the master directory. Everything
+       that is between X_START/X_END or XX_START/XX_END and that
+       is not a label is supposed to be added to the Lump_dir. */
+    Wad_name_c x_start("%c_START", label);
+    Wad_name_c x_end("%c_END", label);
+    Wad_name_c xx_start("%c%c_START", label, label);
+    Wad_name_c xx_end("%c%c_END", label, label);
+    for (MDirPtr dir = *master_dir;
+	 dir && (dir = FindMasterDir(dir, x_start.name, xx_start.name));)
     {
-      if (! dir)
-      {
-	warn ("%.128s: no matching %s for %.*s\n",
-	    start_label->wadfile->pathname (),
-	    end_label,
-	    (int) WAD_NAME, start_label->dir.name);
-	break;
-      }
-      // Ended by X_END or, if started by XX_START, XX_END.
-      if (! x_end.cmp (dir->dir.name)
-	|| end_label == xx_end.name && ! xx_end.cmp (dir->dir.name))
-      {
-	if (dir->dir.size != 0)
-	  warn ("%.128s: label %.*s has non-zero size %ld\n",
-	      dir->wadfile->pathname (),
-	      (int) WAD_NAME, dir->dir.name,
-	      (long) dir->dir.size);
+	MDirPtr start_label = dir;
+	const char *end_label = 0;
+	if (!x_start.cmp(dir->dir.name))
+	    end_label = x_end.name;
+	else if (!xx_start.cmp(dir->dir.name))
+	    end_label = xx_end.name;
+	else
+	    fatal_error("Bad start label \"%.*s\"", (int) WAD_NAME,
+			dir->dir.name);
 	dir = dir->next;
-	break;
-      } 
-      // Ignore inner labels (X[123]_START, X[123]_END)
-      if (dir->dir.start == 0 || dir->dir.size == 0)
-      {
-	if (! (toupper (dir->dir.name[0]) == label
-	    && (dir->dir.name[1] == '1'
-	     || dir->dir.name[1] == '2'
-	     || dir->dir.name[1] == '3')
-	    && dir->dir.name[2] == '_'
-	    && (! y_strnicmp (dir->dir.name + 3, "START", WAD_NAME - 3)
-		|| ! y_strnicmp (dir->dir.name + 3, "END", WAD_NAME - 3))))
-	  warn ("%.128s: unexpected label \"%.*s\" in %s group\n",
-	      dir->wadfile->pathname (),
-	      (int) WAD_NAME, dir->dir.name,
-	      start_label->dir.name);
-	continue;
-      }
-      wad_flat_name_t name;
-      memcpy (name, dir->dir.name, sizeof name);
-      lump_map[name]
-	= Lump_loc (dir->wadfile, dir->dir.start, dir->dir.size);
+	for (;; dir = dir->next)
+	{
+	    if (!dir)
+	    {
+		warn("%.128s: no matching %s for %.*s\n",
+		     start_label->wadfile->pathname(),
+		     end_label, (int) WAD_NAME, start_label->dir.name);
+		break;
+	    }
+	    // Ended by X_END or, if started by XX_START, XX_END.
+	    if (!x_end.cmp(dir->dir.name)
+		|| end_label == xx_end.name && !xx_end.cmp(dir->dir.name))
+	    {
+		if (dir->dir.size != 0)
+		    warn("%.128s: label %.*s has non-zero size %ld\n",
+			 dir->wadfile->pathname(),
+			 (int) WAD_NAME, dir->dir.name, (long) dir->dir.size);
+		dir = dir->next;
+		break;
+	    }
+	    // Ignore inner labels (X[123]_START, X[123]_END)
+	    if (dir->dir.start == 0 || dir->dir.size == 0)
+	    {
+		if (!(toupper(dir->dir.name[0]) == label
+		      && (dir->dir.name[1] == '1'
+			  || dir->dir.name[1] == '2'
+			  || dir->dir.name[1] == '3')
+		      && dir->dir.name[2] == '_'
+		      &&
+		      (!y_strnicmp(dir->dir.name + 3, "START", WAD_NAME - 3)
+		       || !y_strnicmp(dir->dir.name + 3, "END",
+				      WAD_NAME - 3))))
+		    warn("%.128s: unexpected label \"%.*s\" in %s group\n",
+			 dir->wadfile->pathname(), (int) WAD_NAME,
+			 dir->dir.name, start_label->dir.name);
+		continue;
+	    }
+	    wad_flat_name_t name;
+	    memcpy(name, dir->dir.name, sizeof name);
+	    lump_map[name]
+		= Lump_loc(dir->wadfile, dir->dir.start, dir->dir.size);
+	}
+	if (dir)
+	    dir = dir->next;
     }
-    if (dir)
-      dir = dir->next;
-  }
 #ifdef DEBUG
-  for (Lump_lumps_map::const_iterator i = lump_map.begin ();
-      i != lump_map.end (); i++)
-  {
-    printf ("%-8.8s %p %08lX %ld\n",
-      i->first._name,
-      i->second.wad,
-      i->second.ofs,
-      i->second.len);
-  }
+    for (Lump_lumps_map::const_iterator i = lump_map.begin();
+	 i != lump_map.end(); i++)
+    {
+	printf("%-8.8s %p %08lX %ld\n",
+	       i->first._name, i->second.wad, i->second.ofs, i->second.len);
+    }
 #endif
-  dependency->update ();
+    dependency->update();
 }
 
 
 /*-------------------------- Lump_list --------------------------*/
 
 
-Lump_list::Lump_list ()
+Lump_list::Lump_list()
 {
-  array = 0;
-  nelements = 0;
+    array = 0;
+    nelements = 0;
 }
 
 
-Lump_list::~Lump_list ()
+Lump_list::~Lump_list()
 {
-  clear ();
+    clear();
 }
 
 
-void Lump_list::set (Lump_map& lump_map)
+void Lump_list::set(Lump_map & lump_map)
 {
-  clear ();
-  nelements = lump_map.size ();
-  array = new char *[nelements];
+    clear();
+    nelements = lump_map.size();
+    array = new char *[nelements];
 
-  Lump_map::const_iterator i = lump_map.begin ();
-  for (size_t n = 0; n < nelements; n++)
-  {
-    array[n] = new char[WAD_NAME + 1];
-    *array[n] = '\0';
-    strncat (array[n], i++->first.name, WAD_NAME);
-  }
+    Lump_map::const_iterator i = lump_map.begin();
+    for (size_t n = 0; n < nelements; n++)
+    {
+	array[n] = new char[WAD_NAME + 1];
+	*array[n] = '\0';
+	strncat(array[n], i++->first.name, WAD_NAME);
+    }
 }
 
 
-void Lump_list::clear ()
+void Lump_list::clear()
 {
-  if (array != 0)
-  {
-    for (size_t n = 0; n < nelements; n++)
-      delete[] array[n];
-    delete[] array;
-  }
+    if (array != 0)
+    {
+	for (size_t n = 0; n < nelements; n++)
+	    delete[]array[n];
+	delete[]array;
+    }
 }
 
 
-const char **Lump_list::data ()
+const char **Lump_list::data()
 {
-  return (const char **) array;
+    return (const char **) array;
 }
 
 
-size_t Lump_list::size ()
+size_t Lump_list::size()
 {
-  return nelements;
+    return nelements;
 }
 
 
@@ -272,10 +269,9 @@
 
 
 bool Lump_map_less::operator ()
-  (const Wad_name& name1, const Wad_name& name2) const
-{
-  return name1.less (name2);
-  //return y_strnicmp ((const char *) &p1, (const char *) &p2, WAD_NAME) < 0;
-}
-
-
+    (const Wad_name & name1, const Wad_name & name2)
+     const
+     {
+	 return name1.less(name2);
+	 //return y_strnicmp ((const char *) &p1, (const char *) &p2, WAD_NAME) < 0;
+     }
--- a/src/lumpdir.h	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/lumpdir.h	Sat Sep 24 14:16:04 2011 +0300
@@ -28,7 +28,7 @@
 */
 
 
-#ifndef YH_LUMPDIR  /* DO NOT INSERT ANYTHING BEFORE THIS LINE */
+#ifndef YH_LUMPDIR		/* DO NOT INSERT ANYTHING BEFORE THIS LINE */
 #define YH_LUMPDIR
 
 
@@ -66,55 +66,51 @@
 // The key of the map is the lump name
 struct Lump_map_key
 {
-  Lump_map_key (const char *name);
-  wad_name_t _name;
+    Lump_map_key(const char *name);
+    wad_name_t _name;
 };
 
 // How to compare two keys
 struct Lump_map_less
 {
-  //bool operator() (const Lump_map_key& p1, const Lump_map_key& p2) const;
-  bool operator() (const Wad_name& p1, const Wad_name& p2) const;
+    //bool operator() (const Lump_map_key& p1, const Lump_map_key& p2) const;
+    bool operator() (const Wad_name & p1, const Wad_name & p2) const;
 };
 
-typedef std::map<Wad_name, Lump_loc, Lump_map_less> Lump_map;
+typedef std::map < Wad_name, Lump_loc, Lump_map_less > Lump_map;
 
 class Lump_list
 {
-  public :
-    Lump_list ();
-    ~Lump_list ();
-    const char **data ();
-    size_t size ();
-    void set (Lump_map& lump_map);
-    void clear ();
+    public: Lump_list();
+    ~Lump_list();
+    const char **data();
+    size_t size();
+    void set(Lump_map & lump_map);
+    void clear();
 
-  private :
-    char **array;
+    private: char **array;
     size_t nelements;
 };
 
 class Lump_dir
 {
-  public :
-    Lump_dir (MDirPtr *md, char l, Serial_num *sn);
-    ~Lump_dir ();
-    void loc_by_name (const char *name, Lump_loc& loc);
-    void list (Lump_list& l);
+    public: Lump_dir(MDirPtr * md, char l, Serial_num * sn);
+     ~Lump_dir();
+    void loc_by_name(const char *name, Lump_loc & loc);
+    void list(Lump_list & l);
 
-  protected :
-    void refresh ();
+    protected: void refresh();
 
-    Dependency *dependency;		// Resource on which we depend
-    MDirPtr    *master_dir;
-    char       label;			// First character of label
-    Lump_map   lump_map;		// List of lumps, sorted by name
-					// (no duplicates), with their
-					// location.
-    bool       have_prev;
-    Lump_loc   loc_prev;
+    Dependency *dependency;	// Resource on which we depend
+    MDirPtr *master_dir;
+    char label;			// First character of label
+    Lump_map lump_map;		// List of lumps, sorted by name
+    // (no duplicates), with their
+    // location.
+    bool have_prev;
+    Lump_loc loc_prev;
     wad_name_t name_prev;
 };
 
 
-#endif  /* DO NOT ADD ANYTHING AFTER THIS LINE */
+#endif /* DO NOT ADD ANYTHING AFTER THIS LINE */
--- a/src/macro.cc	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/macro.cc	Sat Sep 24 14:16:04 2011 +0300
@@ -68,60 +68,60 @@
  *	the first macro that could not be expanded, starting
  *	from 1.
  */
-int macro_expand (char *buf, size_t size, const char *fmt, ...)
+int macro_expand(char *buf, size_t size, const char *fmt, ...)
 {
-  va_list list;
-  va_start (list, fmt);
-  return vmacro_expand (buf, size, fmt, list);
+    va_list list;
+    va_start(list, fmt);
+    return vmacro_expand(buf, size, fmt, list);
 }
 
 
-int vmacro_expand (char *buf, size_t size, const char *fmt, va_list list)
+int vmacro_expand(char *buf, size_t size, const char *fmt, va_list list)
 {
-  int rc = 0;
-  int macro_no = 0;
+    int rc = 0;
+    int macro_no = 0;
 
-  *buf = '\0';
-  // This is awful, but who cares ?
-  while (*fmt)
-  {
-    va_list l;
-    const char *macro_name = 0;
-    const char *macro_value = 0;
+    *buf = '\0';
+    // This is awful, but who cares ?
+    while (*fmt)
+    {
+	va_list l;
+	const char *macro_name = 0;
+	const char *macro_value = 0;
 
 #ifdef __va_copy
-    __va_copy(l, list);
+	__va_copy(l, list);
 #else
-    l = list;
+	l = list;
 #endif
 
-    while (macro_name = va_arg (l, const char *))
-    {
-      macro_value = va_arg (l, const char *);
-      size_t len1 = strlen (fmt);
-      size_t len2 = strlen (macro_name);
-      if (len1 >= len2 && ! memcmp (fmt, macro_name, len2))
-	break;
+	while (macro_name = va_arg(l, const char *))
+	{
+	    macro_value = va_arg(l, const char *);
+	    size_t len1 = strlen(fmt);
+	    size_t len2 = strlen(macro_name);
+	    if (len1 >= len2 && !memcmp(fmt, macro_name, len2))
+		break;
+	}
+	if (macro_name != 0)
+	{
+	    macro_no++;
+	    if (macro_value == 0)
+	    {
+		if (rc == 0)
+		    rc = macro_no;
+	    }
+	    else
+		al_saps(buf, macro_value, size);
+	    fmt += strlen(macro_name);
+	}
+	else
+	{
+	    al_sapc(buf, *fmt, size);
+	    fmt++;
+	}
     }
-    if (macro_name != 0)
-    {
-      macro_no++;
-      if (macro_value == 0)
-      {
-	if (rc == 0)
-	  rc = macro_no;
-      }
-      else
-        al_saps (buf, macro_value, size);
-      fmt += strlen (macro_name);
-    }
-    else
-    {
-      al_sapc (buf, *fmt, size);
-      fmt++;
-    }
-  }
-  return rc;
+    return rc;
 }
 
 
@@ -171,54 +171,54 @@
  *	the first macro that could not be expanded, starting
  *	from 1.
  */
-template <typename const_iterator>
-int macro_expand (char *buf, size_t size, const char *fmt,
-  const_iterator macdef_begin, const_iterator macdef_end)
+template < typename const_iterator >
+    int macro_expand(char *buf, size_t size, const char *fmt,
+		     const_iterator macdef_begin, const_iterator macdef_end)
 {
-  int rc = 0;
-  int macro_no = 0;
+    int rc = 0;
+    int macro_no = 0;
 
-  *buf = '\0';
-  size_t fmt_len = strlen (fmt);
-  while (*fmt != '\0')
-  {
-    const char *macro_name     = 0;
-    const char *macro_value    = 0;
-    size_t      macro_name_len = 0;
-    bool        match          = false;
-    for (const_iterator i = macdef_begin; i != macdef_end; ++i)
+    *buf = '\0';
+    size_t fmt_len = strlen(fmt);
+    while (*fmt != '\0')
     {
-      macro_name     = i->name;
-      macro_value    = i->value;
-      macro_name_len = strlen (macro_name);
-      if (macro_name_len <= fmt_len
-	  && memcmp (fmt, macro_name, macro_name_len) == 0)
-      {
-	match = true;
-	break;
-      }
+	const char *macro_name = 0;
+	const char *macro_value = 0;
+	size_t macro_name_len = 0;
+	bool match = false;
+	for (const_iterator i = macdef_begin; i != macdef_end; ++i)
+	{
+	    macro_name = i->name;
+	    macro_value = i->value;
+	    macro_name_len = strlen(macro_name);
+	    if (macro_name_len <= fmt_len
+		&& memcmp(fmt, macro_name, macro_name_len) == 0)
+	    {
+		match = true;
+		break;
+	    }
+	}
+	if (match)
+	{
+	    macro_no++;
+	    if (macro_value == 0)
+	    {
+		if (rc == 0)
+		    rc = macro_no;
+	    }
+	    else
+		al_saps(buf, macro_value, size);
+	    fmt += macro_name_len;
+	    fmt_len -= macro_name_len;
+	}
+	else
+	{
+	    al_sapc(buf, *fmt, size);
+	    fmt++;
+	    fmt_len--;
+	}
     }
-    if (match)
-    {
-      macro_no++;
-      if (macro_value == 0)
-      {
-	if (rc == 0)
-	  rc = macro_no;
-      }
-      else
-        al_saps (buf, macro_value, size);
-      fmt     += macro_name_len;
-      fmt_len -= macro_name_len;
-    }
-    else
-    {
-      al_sapc (buf, *fmt, size);
-      fmt++;
-      fmt_len--;
-    }
-  }
-  return rc;
+    return rc;
 }
 
 
@@ -235,29 +235,31 @@
 
 struct macdef
 {
-  const char *name;
-  const char *value;
-  macdef (const char *name, const char *value) :
-    name (name), value (value) { }
+    const char *name;
+    const char *value;
+      macdef(const char *name, const char *value):name(name), value(value)
+    {
+    }
 };
 
 
-void dump (const macdef& m)
+void dump(const macdef & m)
 {
-  fprintf (stderr, "%s=%s\n", m.name, m.value);
+    fprintf(stderr, "%s=%s\n", m.name, m.value);
 }
 
 
-int main ()
+int main()
 {
-  char buf[100];
-  std::list<macdef> macdefs;
-  macdefs.push_back (macdef ("%b", "1"));
-  macdefs.push_back (macdef ("%bc", "2"));
-  std::for_each (macdefs.begin (), macdefs.end (), dump);
-  macro_expand (buf, sizeof buf - 1, "a%bcd", macdefs.begin (), macdefs.end ());
-  puts (buf);
-  return 0;
+    char buf[100];
+    std::list < macdef > macdefs;
+    macdefs.push_back(macdef("%b", "1"));
+    macdefs.push_back(macdef("%bc", "2"));
+    std::for_each(macdefs.begin(), macdefs.end(), dump);
+    macro_expand(buf, sizeof buf - 1, "a%bcd", macdefs.begin(),
+		 macdefs.end());
+    puts(buf);
+    return 0;
 }
 
 
--- a/src/macro.h	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/macro.h	Sat Sep 24 14:16:04 2011 +0300
@@ -30,13 +30,12 @@
 
 typedef struct
 {
-  const char *name;
-  const char *value;
+    const char *name;
+    const char *value;
 } macdef_t;
 
 
-int macro_expand (char *buf, size_t size, const char *fmt, ...);
-int macro_expand (char *buf, size_t size, const char *fmt, const macdef_t *def);
-int vmacro_expand (char *buf, size_t size, const char *fmt, va_list list);
-
-
+int macro_expand(char *buf, size_t size, const char *fmt, ...);
+int macro_expand(char *buf, size_t size, const char *fmt,
+		 const macdef_t * def);
+int vmacro_expand(char *buf, size_t size, const char *fmt, va_list list);
--- a/src/masterdir.h	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/masterdir.h	Sat Sep 24 14:16:04 2011 +0300
@@ -5,17 +5,15 @@
  */
 
 
-#ifndef YH_MASTERDIR  /* DO NOT INSERT ANYTHING BEFORE THIS LINE */
+#ifndef YH_MASTERDIR		/* DO NOT INSERT ANYTHING BEFORE THIS LINE */
 #define YH_MASTERDIR
 
 
 class Master_dir
 {
-  public :
-    Master_dir ();
-  private :
-    Serial_num serial;
+    public:Master_dir();
+    private:Serial_num serial;
 };
 
 
-#endif  /* DO NOT ADD ANYTHING AFTER THIS LINE */
+#endif /* DO NOT ADD ANYTHING AFTER THIS LINE */
--- a/src/memory.cc	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/memory.cc	Sat Sep 24 14:16:04 2011 +0300
@@ -45,34 +45,35 @@
 */
 
 #define SIZE_THRESHOLD	1024
-#define SIZE_OF_BLOCK	4095  /* actually, this is (size - 1) */
+#define SIZE_OF_BLOCK	4095	/* actually, this is (size - 1) */
 
 
 /*
    allocate memory with error checking
 */
 
-void *GetMemory (unsigned long size)
+void *GetMemory(unsigned long size)
 {
-void *ret;
+    void *ret;
 
 /* On 16-bit systems (BC 4.0), size_t is only 16-bit long so
    you can't malloc() more than 64 kB at a time. Catch it. */
-if (size != (size_t) size)
-   fatal_error ("GetMemory: %lu B is too much for this poor machine.", size);
+    if (size != (size_t) size)
+	fatal_error("GetMemory: %lu B is too much for this poor machine.",
+		    size);
 
 /* limit fragmentation on large blocks */
-if (size >= SIZE_THRESHOLD)
-   size = (size + SIZE_OF_BLOCK) & ~SIZE_OF_BLOCK;
-ret = malloc ((size_t) size);
-if (!ret)
-   {
-   /* retry after having freed some memory, if possible */
-   ret = malloc ((size_t) size);
-   }
-if (!ret)
-   fatal_error ("out of memory (cannot allocate %u bytes)", size);
-return ret;
+    if (size >= SIZE_THRESHOLD)
+	size = (size + SIZE_OF_BLOCK) & ~SIZE_OF_BLOCK;
+    ret = malloc((size_t) size);
+    if (!ret)
+    {
+	/* retry after having freed some memory, if possible */
+	ret = malloc((size_t) size);
+    }
+    if (!ret)
+	fatal_error("out of memory (cannot allocate %u bytes)", size);
+    return ret;
 }
 
 
@@ -80,26 +81,27 @@
    reallocate memory with error checking
 */
 
-void *ResizeMemory (void *old, unsigned long size)
+void *ResizeMemory(void *old, unsigned long size)
 {
-void *ret;
+    void *ret;
 
 /* On 16-bit systems (BC 4.0), size_t is only 16-bit long so
    you can't malloc() more than 64 kB at a time. Catch it. */
-if (size != (size_t) size)
-   fatal_error ("ResizeMemory: %lu B is too much for this poor machine.", size);
+    if (size != (size_t) size)
+	fatal_error("ResizeMemory: %lu B is too much for this poor machine.",
+		    size);
 
 /* limit fragmentation on large blocks */
-if (size >= SIZE_THRESHOLD)
-   size = (size + SIZE_OF_BLOCK) & ~SIZE_OF_BLOCK;
-ret = realloc (old, (size_t) size);
-if (!ret)
-   {
-   ret = realloc (old, (size_t) size);
-   }
-if (!ret)
-   fatal_error ("out of memory (cannot reallocate %lu bytes)", size);
-return ret;
+    if (size >= SIZE_THRESHOLD)
+	size = (size + SIZE_OF_BLOCK) & ~SIZE_OF_BLOCK;
+    ret = realloc(old, (size_t) size);
+    if (!ret)
+    {
+	ret = realloc(old, (size_t) size);
+    }
+    if (!ret)
+	fatal_error("out of memory (cannot reallocate %lu bytes)", size);
+    return ret;
 }
 
 
@@ -107,11 +109,11 @@
    free memory
 */
 
-void FreeMemory (void *ptr)
+void FreeMemory(void *ptr)
 {
 /* just a wrapper around free(), but provide an entry point */
 /* for memory debugging routines... */
-free (ptr);
+    free(ptr);
 }
 
 
--- a/src/menu.cc	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/menu.cc	Sat Sep 24 14:16:04 2011 +0300
@@ -49,7 +49,7 @@
 const unsigned char MIF_MTICK = 0x0c;
 const unsigned char MIF_SEPAR = 0x10;
 
-const short VSPACE = 2;				// Pixels between items
+const short VSPACE = 2;		// Pixels between items
 
 
 /* 
@@ -57,41 +57,40 @@
  */
 class Menu_item
 {
-  public :
-    Menu_item ()
+    public: Menu_item()
     {
-      flags          = MIF_NTICK | MIF_NACTIVE;
-      tilde_key      = YK_;
-      shortcut_key   = YK_;
-      str            = 0;
+	flags = MIF_NTICK | MIF_NACTIVE;
+	tilde_key = YK_;
+	shortcut_key = YK_;
+	str = 0;
     }
 
     unsigned char flags;	// Logical-or of MIF_?ACTIVE MIF_?TICK MIF_SEPAR
-    inpev_t       tilde_key;
-    inpev_t       shortcut_key;
-    short         y;		// Top of item, relative to ly0. If there is a
-				// separation, it is above y.
-    const char    *str;
+    inpev_t tilde_key;
+    inpev_t shortcut_key;
+    short y;			// Top of item, relative to ly0. If there is a
+    // separation, it is above y.
+    const char *str;
     union
     {
-      bool s;			// Static
-      bool *v;			// Pointer to variable
-      struct
-      {
-	micb_t f;		// Pointer to callback function
-	micbarg_t a;		// Argument
-      } f;
+	bool s;			// Static
+	bool *v;		// Pointer to variable
+	struct
+	{
+	    micb_t f;		// Pointer to callback function
+	    micbarg_t a;	// Argument
+	} f;
     }
     tick;
     union
     {
-      bool s;			// Static
-      bool *v;			// Pointer to variable
-      struct
-      {
-	micb_t f;		// Pointer to callback function
-	micbarg_t a;		// Argument
-      } f;
+	bool s;			// Static
+	bool *v;		// Pointer to variable
+	struct
+	{
+	    micb_t f;		// Pointer to callback function
+	    micbarg_t a;	// Argument
+	} f;
     }
     active;
 };
@@ -102,78 +101,76 @@
  */
 class Menu_priv
 {
-  public :
-
-    Menu_priv ()
+    public:Menu_priv()
     {
-      flags         = 0;
-      title         = 0;
-      title_len     = 0;
-      items_ks_len  = 0;
-      items_len     = 0;
-      items.clear ();
-      user_ox0      = -1;
-      user_oy0      = -1;
-      ox0           = -1;
-      oy0           = -1;
-      need_geom     = true;
-      visible       = false;
-      visible_disp  = false;
-      line          = 0;
-      line_disp     = UINT_MAX;
-      item_height   = FONTH + VSPACE;
+	flags = 0;
+	title = 0;
+	title_len = 0;
+	items_ks_len = 0;
+	items_len = 0;
+	items.clear();
+	user_ox0 = -1;
+	user_oy0 = -1;
+	ox0 = -1;
+	oy0 = -1;
+	need_geom = true;
+	visible = false;
+	visible_disp = false;
+	line = 0;
+	line_disp = UINT_MAX;
+	item_height = FONTH + VSPACE;
     }
 
-    void vinit (Menu& m, const char *title, va_list argp);
-    void cook ();
-    void draw ();
-    void draw_one_line (size_t line, bool highlighted);
-    void geom ();
-    int process_event (const input_status_t *is);
+    void vinit(Menu & m, const char *title, va_list argp);
+    void cook();
+    void draw();
+    void draw_one_line(size_t line, bool highlighted);
+    void geom();
+    int process_event(const input_status_t * is);
 
     // Menu data
     unsigned char flags;	// MF_MENUDATA
-				//          The strings come from a Menu_data.
-				// MF_POPUP Used as popup (not pull-down) menu
-				//          If set, the title is shown and
-				//          button releases are treated
-				//          differently.
-				// MF_TICK  At least one item can be ticked
-				//          (has the MIF_[SVF]TICK flag).
-				// MF_SHORTCUT  At least one item has a key
-				//          shortcut key.
-				// MF_NUMS  Force the use of standard
-				//          shortcuts [0-9a-zA-Z] even if
-				//          index/key shortcuts exist.
+    //          The strings come from a Menu_data.
+    // MF_POPUP Used as popup (not pull-down) menu
+    //          If set, the title is shown and
+    //          button releases are treated
+    //          differently.
+    // MF_TICK  At least one item can be ticked
+    //          (has the MIF_[SVF]TICK flag).
+    // MF_SHORTCUT  At least one item has a key
+    //          shortcut key.
+    // MF_NUMS  Force the use of standard
+    //          shortcuts [0-9a-zA-Z] even if
+    //          index/key shortcuts exist.
     const char *title;		// NULL if no title
-    size_t     title_len;	// Length of <title> (or 0 if none)
-    size_t     items_ks_len;	// Length of the longest item counting key sc.
-    size_t     items_len;	// Length of the longest item not counting k.s.
+    size_t title_len;		// Length of <title> (or 0 if none)
+    size_t items_ks_len;	// Length of the longest item counting key sc.
+    size_t items_len;		// Length of the longest item not counting k.s.
     const Menu_data *menudata;
-    std::vector<Menu_item> items;
+    std::vector < Menu_item > items;
 
     // Geometry as the user would like it to be
-    int    user_ox0;		// Top left corner. < 0 means centered.
-    int    user_oy0;		// Top left corner. < 0 means centered.
+    int user_ox0;		// Top left corner. < 0 means centered.
+    int user_oy0;		// Top left corner. < 0 means centered.
 
     // Geometry as it should be
-    int    ix0, iy0, ix1, iy1;	// Corners of inner edge of window
-    int    ox0, oy0, ox1, oy1;	// Corners of outer edge of window
-    int    width;		// Overall width of window
-    int    height;		// Overall height of window
-    int    ty0;			// Y-pos of title
-    int    ly0;			// Y-pos of first item
+    int ix0, iy0, ix1, iy1;	// Corners of inner edge of window
+    int ox0, oy0, ox1, oy1;	// Corners of outer edge of window
+    int width;			// Overall width of window
+    int height;			// Overall height of window
+    int ty0;			// Y-pos of title
+    int ly0;			// Y-pos of first item
 
     // Geometry as it is displayed
-    int    ox0_disp;
-    int    oy0_disp;
-    int    width_disp;
-    int    height_disp;
+    int ox0_disp;
+    int oy0_disp;
+    int width_disp;
+    int height_disp;
 
     // Status
-    bool   need_geom;		// Need to call geom() again
-    bool   visible;		// Should the menu be visible ?
-    bool   visible_disp;	// Is it really visible ?
+    bool need_geom;		// Need to call geom() again
+    bool visible;		// Should the menu be visible ?
+    bool visible_disp;		// Is it really visible ?
     size_t line;		// Which line should be highlighted ?
     size_t line_disp;		// Which line is actually highlighted ?
     inpev_t _last_shortcut_key;	// Shortcut key for last selected item.
@@ -185,23 +182,22 @@
 
 /* First subscript :  0 = normal, 1 = greyed out
    Second subscript : 0 = normal, 1 = highlighted */
-const colour_pair_t menu_colour[2][2] =
-{
-  {
-    { WINBG,    WINFG        },    // Normal entry
-    { WINBG_HL, WINFG_HL     }     // Normal entry, highlighted
-  },
-  {
-    { WINBG,    WINFG_DIM    },    // Greyed out entry
-    { WINBG_HL, WINFG_DIM_HL }     // Greyed out entry, highlighted
-  }
+const colour_pair_t menu_colour[2][2] = {
+    {
+     {WINBG, WINFG},		// Normal entry
+     {WINBG_HL, WINFG_HL}	// Normal entry, highlighted
+     },
+    {
+     {WINBG, WINFG_DIM},	// Greyed out entry
+     {WINBG_HL, WINFG_DIM_HL}	// Greyed out entry, highlighted
+     }
 };
 
-const unsigned char MF_POPUP    = 0x01;
-const unsigned char MF_TICK     = 0x02;
-const unsigned char MF_TILDE    = 0x04;
+const unsigned char MF_POPUP = 0x01;
+const unsigned char MF_TICK = 0x02;
+const unsigned char MF_TILDE = 0x04;
 const unsigned char MF_SHORTCUT = 0x08;
-const unsigned char MF_NUMS     = 0x10;
+const unsigned char MF_NUMS = 0x10;
 const unsigned char MF_MENUDATA = 0x20;
 
 
@@ -321,14 +317,14 @@
  *	but will not be reflected until the menu is redrawn from
  *	scratch.
  */
-Menu::Menu (const char *title, ...)
+Menu::Menu(const char *title, ...)
 {
-  priv = new Menu_priv;
-  va_list argp;
-  va_start (argp, title);
-  priv->vinit (*this, title, argp);
-  va_end (argp);
-  priv->cook ();
+    priv = new Menu_priv;
+    va_list argp;
+    va_start(argp, title);
+    priv->vinit(*this, title, argp);
+    va_end(argp);
+    priv->cook();
 }
 
 
@@ -339,11 +335,11 @@
  *	*title, ...) except that it expects a pointer on the
  *	list of arguments.
  */
-Menu::Menu (const char *title, va_list argp)
+Menu::Menu(const char *title, va_list argp)
 {
-  priv = new Menu_priv;
-  priv->vinit (*this, title, argp);
-  priv->cook ();
+    priv = new Menu_priv;
+    priv->vinit(*this, title, argp);
+    priv->cook();
 }
 
 
@@ -353,120 +349,117 @@
  *	Another ctor for Menu, suited to the creation of the
  *	menu from a list.
  */
-Menu::Menu (
-   const char   *title,
-   al_llist_t   *list,
-   const char   *(*getstr) (void *))
+Menu::Menu(const char *title,
+	   al_llist_t * list, const char *(*getstr) (void *))
 {
-  priv = new Menu_priv;
-  set_title (title);
-  size_t nitems = y_min (al_lcount (list), 100);
-  priv->items.resize (nitems);
-  size_t line;
-  for (al_lrewind (list), line = 0;
-       ! al_leol (list) && line < nitems;
-       al_lstep (list), line++)
-    priv->items[line].str = getstr (al_lptr (list));
-  priv->cook ();
+    priv = new Menu_priv;
+    set_title(title);
+    size_t nitems = y_min(al_lcount(list), 100);
+    priv->items.resize(nitems);
+    size_t line;
+    for (al_lrewind(list), line = 0;
+	 !al_leol(list) && line < nitems; al_lstep(list), line++)
+	priv->items[line].str = getstr(al_lptr(list));
+    priv->cook();
 }
 
 
 /*
  *	Menu::Menu - ctor from a Menu_data
  */
-Menu::Menu (const char *title, const Menu_data& menudata)
+Menu::Menu(const char *title, const Menu_data & menudata)
 {
-  priv = new Menu_priv;
-  priv->menudata = &menudata;
-  priv->flags |= MF_MENUDATA;
-  set_title (title);
-  size_t nitems = menudata.nitems ();
-  priv->items.resize (nitems);
-  priv->cook ();
+    priv = new Menu_priv;
+    priv->menudata = &menudata;
+    priv->flags |= MF_MENUDATA;
+    set_title(title);
+    size_t nitems = menudata.nitems();
+    priv->items.resize(nitems);
+    priv->cook();
 }
 
 
 /*
  *	Menu::~Menu - dtor
  */
-Menu::~Menu ()
+Menu::~Menu()
 {
-  delete priv;
+    delete priv;
 }
 
 
 /*
  *	Menu_priv::vinit - initialize the menu from an argument list
  */
-void Menu_priv::vinit (Menu& m, const char *title, va_list argp)
+void Menu_priv::vinit(Menu & m, const char *title, va_list argp)
 {
-  bool tick = false;
-
-  m.set_title (title);
-
-  while (items.size () < 100)
-  {
-    Menu_item i;
+    bool tick = false;
 
-    const char *str = va_arg (argp, const char *);
-    while (str == MI_SEPARATION)
-    {
-      i.flags |= MIF_SEPAR;
-      str = va_arg (argp, const char *);
-    }
-    if (str == 0)
-      break;
+    m.set_title(title);
 
-    i.str            = str;
-    i.shortcut_key   = (inpev_t) va_arg (argp, int);
-    unsigned char flag;
-    while ((flag = (unsigned char) va_arg (argp, int)) != 0)
+    while (items.size() < 100)
     {
-      if (flag == MIF_SACTIVE)
-      {
-	i.flags  = (i.flags & ~MIF_MACTIVE) | MIF_SACTIVE;
-	i.active.s = (bool) va_arg (argp, int);
-      }
-      else if (flag == MIF_VACTIVE)
-      {
-	i.flags  = (i.flags & ~MIF_MACTIVE) | MIF_VACTIVE;
-	i.active.v = va_arg (argp, bool *);
-      }
-      else if (flag == MIF_FACTIVE)
-      {
-	i.flags  = (i.flags & ~MIF_MACTIVE) | MIF_FACTIVE;
-	i.active.f.f = va_arg (argp, micb_t);
-	i.active.f.a = va_arg (argp, micbarg_t);
-      }
-      else if (flag == MIF_STICK)
-      {
-	tick = true;
-	i.flags  = (i.flags & ~MIF_MTICK) | MIF_STICK;
-	i.tick.s = (bool) va_arg (argp, int);
-      }
-      else if (flag == MIF_VTICK)
-      {
-	tick = true;
-	i.flags  = (i.flags & ~MIF_MTICK) | MIF_VTICK;
-	i.tick.v = va_arg (argp, bool *);
-      }
-      else if (flag == MIF_FTICK)
-      {
-	tick = true;
-	i.flags  = (i.flags & ~MIF_MTICK) | MIF_FTICK;
-	i.tick.f.f = va_arg (argp, micb_t);
-	i.tick.f.a = va_arg (argp, micbarg_t);
-      }
-      else if (flag != 0)
-      {
-	nf_bug ("Menu::ctor: flag %d", (int) flag);
-      }
+	Menu_item i;
+
+	const char *str = va_arg(argp, const char *);
+	while (str == MI_SEPARATION)
+	{
+	    i.flags |= MIF_SEPAR;
+	    str = va_arg(argp, const char *);
+	}
+	if (str == 0)
+	    break;
+
+	i.str = str;
+	i.shortcut_key = (inpev_t) va_arg(argp, int);
+	unsigned char flag;
+	while ((flag = (unsigned char) va_arg(argp, int)) != 0)
+	{
+	    if (flag == MIF_SACTIVE)
+	    {
+		i.flags = (i.flags & ~MIF_MACTIVE) | MIF_SACTIVE;
+		i.active.s = (bool) va_arg(argp, int);
+	    }
+	    else if (flag == MIF_VACTIVE)
+	    {
+		i.flags = (i.flags & ~MIF_MACTIVE) | MIF_VACTIVE;
+		i.active.v = va_arg(argp, bool *);
+	    }
+	    else if (flag == MIF_FACTIVE)
+	    {
+		i.flags = (i.flags & ~MIF_MACTIVE) | MIF_FACTIVE;
+		i.active.f.f = va_arg(argp, micb_t);
+		i.active.f.a = va_arg(argp, micbarg_t);
+	    }
+	    else if (flag == MIF_STICK)
+	    {
+		tick = true;
+		i.flags = (i.flags & ~MIF_MTICK) | MIF_STICK;
+		i.tick.s = (bool) va_arg(argp, int);
+	    }
+	    else if (flag == MIF_VTICK)
+	    {
+		tick = true;
+		i.flags = (i.flags & ~MIF_MTICK) | MIF_VTICK;
+		i.tick.v = va_arg(argp, bool *);
+	    }
+	    else if (flag == MIF_FTICK)
+	    {
+		tick = true;
+		i.flags = (i.flags & ~MIF_MTICK) | MIF_FTICK;
+		i.tick.f.f = va_arg(argp, micb_t);
+		i.tick.f.a = va_arg(argp, micbarg_t);
+	    }
+	    else if (flag != 0)
+	    {
+		nf_bug("Menu::ctor: flag %d", (int) flag);
+	    }
+	}
+	items.push_back(i);
     }
-    items.push_back (i);
-  }
 
-  if (tick)
-    flags |= MF_TICK;
+    if (tick)
+	flags |= MF_TICK;
 }
 
 
@@ -476,60 +469,60 @@
  *	Compute items_len, items_ks_len and prepare the cooked
  *	tilde shortcuts.
  */
-void Menu_priv::cook ()
+void Menu_priv::cook()
 {
-  items_len    = 0;
-  items_ks_len = 0;
-  short y      = 0;
+    items_len = 0;
+    items_ks_len = 0;
+    short y = 0;
 
-  for (size_t line = 0; line < items.size (); line++)
-  {
-    Menu_item& i = items[line];
-    if (i.shortcut_key != YK_)
-      flags |= MF_SHORTCUT;
-    if ((i.flags & MIF_MTICK) != MIF_NTICK)
-      flags |= MF_TICK;
-    if (i.flags & MIF_SEPAR)
-      y += 2 * (NARROW_VSPACING + NARROW_BORDER);
-    i.y = y;
-    y += item_height;
-    size_t len = 0;
-    i.tilde_key = YK_;
-    const char *str = (flags & MF_MENUDATA) ? (*menudata)[line] : i.str;
-    for (const char *p = str; *p != '\0'; p++)
-      if (p[0] == '~' && p[1] != '\0' && i.tilde_key == YK_)
-      {
-	i.tilde_key = tolower (p[1]);
-	flags |= MF_TILDE;
-      }
-      else
-	len++;
-    size_t len_ks = len;
-    if (i.shortcut_key != YK_)
-      len_ks += strlen (key_to_string (i.shortcut_key)) + 2;
-    if (len > items_len)
-      items_len = len;
-    if (len_ks > items_ks_len)
-      items_ks_len = len_ks;
-  }
+    for (size_t line = 0; line < items.size(); line++)
+    {
+	Menu_item & i = items[line];
+	if (i.shortcut_key != YK_)
+	    flags |= MF_SHORTCUT;
+	if ((i.flags & MIF_MTICK) != MIF_NTICK)
+	    flags |= MF_TICK;
+	if (i.flags & MIF_SEPAR)
+	    y += 2 * (NARROW_VSPACING + NARROW_BORDER);
+	i.y = y;
+	y += item_height;
+	size_t len = 0;
+	i.tilde_key = YK_;
+	const char *str = (flags & MF_MENUDATA) ? (*menudata)[line] : i.str;
+	for (const char *p = str; *p != '\0'; p++)
+	    if (p[0] == '~' && p[1] != '\0' && i.tilde_key == YK_)
+	    {
+		i.tilde_key = tolower(p[1]);
+		flags |= MF_TILDE;
+	    }
+	    else
+		len++;
+	size_t len_ks = len;
+	if (i.shortcut_key != YK_)
+	    len_ks += strlen(key_to_string(i.shortcut_key)) + 2;
+	if (len > items_len)
+	    items_len = len;
+	if (len_ks > items_ks_len)
+	    items_ks_len = len_ks;
+    }
 
-  if (flags & MF_TICK)
-  {
-    items_len    += 2;		// Tick mark
-    items_ks_len += 2;
-  }
-  if (flags & MF_SHORTCUT)
-  {
-    items_len    += 4;		// Space between strings and shortcut
-    items_ks_len += 4;
-  }
-  if (! (flags & MF_TILDE) && ! (flags & MF_SHORTCUT))
-    flags |= MF_NUMS;
-  if (flags & MF_NUMS)
-  {
-    items_len    += 4;		// [1-9a-zA-Z] prefix
-    items_ks_len += 4;
-  }
+    if (flags & MF_TICK)
+    {
+	items_len += 2;		// Tick mark
+	items_ks_len += 2;
+    }
+    if (flags & MF_SHORTCUT)
+    {
+	items_len += 4;		// Space between strings and shortcut
+	items_ks_len += 4;
+    }
+    if (!(flags & MF_TILDE) && !(flags & MF_SHORTCUT))
+	flags |= MF_NUMS;
+    if (flags & MF_NUMS)
+    {
+	items_len += 4;		// [1-9a-zA-Z] prefix
+	items_ks_len += 4;
+    }
 }
 
 
@@ -542,17 +535,17 @@
  *	Bug: changing the title does not take effect until the
  *	next display from scratch.
  */
-void Menu::set_title (const char *title)
+void Menu::set_title(const char *title)
 {
-  priv->title = title;
-  size_t title_len = title ? strlen (title) : 0;
+    priv->title = title;
+    size_t title_len = title ? strlen(title) : 0;
 
-  /* If the length of the title has changed,
-     force geom() to be called again. */
-  if (title_len != priv->title_len)
-    priv->need_geom = true;
+    /* If the length of the title has changed,
+       force geom() to be called again. */
+    if (title_len != priv->title_len)
+	priv->need_geom = true;
 
-  priv->title_len = title_len;
+    priv->title_len = title_len;
 }
 
 
@@ -563,13 +556,13 @@
  *	If <x0> is < 0, the window is horizontally centred.
  *	If <y0> is < 0, the window is vertically centred.
  */
-void Menu::set_coords (int x0, int y0)
+void Menu::set_coords(int x0, int y0)
 {
-  if (x0 != priv->ox0 || y0 != priv->oy0)
-    priv->need_geom = true;  // Force geom() to be called
+    if (x0 != priv->ox0 || y0 != priv->oy0)
+	priv->need_geom = true;	// Force geom() to be called
 
-  priv->user_ox0 = x0;
-  priv->user_oy0 = y0;
+    priv->user_ox0 = x0;
+    priv->user_oy0 = y0;
 }
 
 
@@ -579,9 +572,9 @@
  *	The current line number is set to <item_no>. The first
  *	line bears number 0.
  */
-void Menu::set_item_no (int item_no)
+void Menu::set_item_no(int item_no)
 {
-  priv->line = item_no;
+    priv->line = item_no;
 }
 
 
@@ -591,14 +584,14 @@
  *	If <popup> is true, the popup flag is set. If <popup> is
  *	false, the popup flag is cleared.
  */
-void Menu::set_popup (bool popup)
+void Menu::set_popup(bool popup)
 {
-  if (popup != !! (priv->flags & MF_POPUP))
-    priv->need_geom = true;  // Force geom() to be called
-  if (popup)
-    priv->flags |= MF_POPUP;
-  else
-    priv->flags &= ~MF_POPUP;
+    if (popup != ! !(priv->flags & MF_POPUP))
+	priv->need_geom = true;	// Force geom() to be called
+    if (popup)
+	priv->flags |= MF_POPUP;
+    else
+	priv->flags &= ~MF_POPUP;
 }
 
 
@@ -617,14 +610,14 @@
  *	<force_numbers> is automatically set. Otherwise, is it
  *	off by default.
  */
-void Menu::set_force_numbers (bool force_numbers)
+void Menu::set_force_numbers(bool force_numbers)
 {
-  if (force_numbers != !! (priv->flags & MF_NUMS))
-    priv->need_geom = true;  // Force geom() to be called.
-  if (force_numbers)
-    priv->flags |= MF_NUMS;
-  else
-    priv->flags &= ~MF_NUMS;
+    if (force_numbers != ! !(priv->flags & MF_NUMS))
+	priv->need_geom = true;	// Force geom() to be called.
+    if (force_numbers)
+	priv->flags |= MF_NUMS;
+    else
+	priv->flags &= ~MF_NUMS;
 }
 
 
@@ -634,9 +627,9 @@
  *	If <visible> is true, the visible flag is set. If
  *	<visible> is false, the visible flag is cleared.
  */
-void Menu::set_visible (bool visible)
+void Menu::set_visible(bool visible)
 {
-  priv->visible = visible;
+    priv->visible = visible;
 }
 
 
@@ -649,20 +642,20 @@
  *	option, emit a warning and return without doing
  *	anything.
  */
-void Menu::set_ticked (size_t item_no, bool ticked)
+void Menu::set_ticked(size_t item_no, bool ticked)
 {
-  if (item_no >= priv->items.size ())
-  {
-    nf_bug ("Menu::set_ticked: item_no %lu", (unsigned long) item_no);
-    return;
-  }
-  Menu_item& i = priv->items[item_no];
-  if ((i.flags & MIF_MTICK) != MIF_STICK)
-  {
-    nf_bug ("Menu::set_ticked: flags %02X", i.flags);
-    return;
-  }
-  i.tick.s = ticked;
+    if (item_no >= priv->items.size())
+    {
+	nf_bug("Menu::set_ticked: item_no %lu", (unsigned long) item_no);
+	return;
+    }
+    Menu_item & i = priv->items[item_no];
+    if ((i.flags & MIF_MTICK) != MIF_STICK)
+    {
+	nf_bug("Menu::set_ticked: flags %02X", i.flags);
+	return;
+    }
+    i.tick.s = ticked;
 }
 
 
@@ -675,70 +668,69 @@
  *	with with the MIF_SACTIVE option, emit a warning and
  *	return without doing anything.
  */
-void Menu::set_active (size_t item_no, bool active)
+void Menu::set_active(size_t item_no, bool active)
 {
-  if (item_no >= priv->items.size ())
-  {
-    nf_bug ("Menu::set_active: item_no %lu", (unsigned long) item_no);
-    return;
-  }
-  Menu_item& i = priv->items[item_no];
-  if ((i.flags & MIF_MACTIVE) != MIF_SACTIVE)
-  {
-    nf_bug ("Menu::set_active: flags %02Xh", i.flags);
-    return;
-  }
-  i.active.s = active;
+    if (item_no >= priv->items.size())
+    {
+	nf_bug("Menu::set_active: item_no %lu", (unsigned long) item_no);
+	return;
+    }
+    Menu_item & i = priv->items[item_no];
+    if ((i.flags & MIF_MACTIVE) != MIF_SACTIVE)
+    {
+	nf_bug("Menu::set_active: flags %02Xh", i.flags);
+	return;
+    }
+    i.active.s = active;
 }
 
 
 /*
  *	Menu_priv::geom - recalculate the screen coordinates etc.
  */
-void Menu_priv::geom ()
+void Menu_priv::geom()
 {
-  size_t width_chars = 0;
-  if (title && (flags & MF_POPUP))
-    width_chars = y_max (width_chars, title_len);
-  if (flags & MF_NUMS)
-    width_chars = y_max (width_chars, items_len + 4);
-  else
-    width_chars = y_max (width_chars, items_ks_len);
-  int title_height = title && (flags & MF_POPUP) ? (int) (1.5 * FONTH) : 0;
+    size_t width_chars = 0;
+    if (title && (flags & MF_POPUP))
+	width_chars = y_max(width_chars, title_len);
+    if (flags & MF_NUMS)
+	width_chars = y_max(width_chars, items_len + 4);
+    else
+	width_chars = y_max(width_chars, items_ks_len);
+    int title_height = title && (flags & MF_POPUP) ? (int) (1.5 * FONTH) : 0;
 
-  width  = 2 * BOX_BORDER + 2 * WIDE_HSPACING + width_chars * FONTW;
-  height = 2 * BOX_BORDER + 2 * WIDE_VSPACING + title_height
-					      + items.back().y
-					      + item_height;
+    width = 2 * BOX_BORDER + 2 * WIDE_HSPACING + width_chars * FONTW;
+    height = 2 * BOX_BORDER + 2 * WIDE_VSPACING + title_height
+	+ items.back().y + item_height;
 
-  if (user_ox0 < 0)
-    ox0 = (ScrMaxX - width) / 2;
-  else
-    ox0 = user_ox0;
-  ix0 = ox0 + BOX_BORDER;
-  ix1 = ix0 + 2 * WIDE_HSPACING + width_chars * FONTW - 1;
-  ox1 = ix1 + BOX_BORDER;
-  if (ox1 > ScrMaxX)
-  {
-    int overlap = ox1 - ScrMaxX;
-    ox0 -= overlap;
-    ix0 -= overlap;
-    ix1 -= overlap;
-    ox1 -= overlap;
-  }
+    if (user_ox0 < 0)
+	ox0 = (ScrMaxX - width) / 2;
+    else
+	ox0 = user_ox0;
+    ix0 = ox0 + BOX_BORDER;
+    ix1 = ix0 + 2 * WIDE_HSPACING + width_chars * FONTW - 1;
+    ox1 = ix1 + BOX_BORDER;
+    if (ox1 > ScrMaxX)
+    {
+	int overlap = ox1 - ScrMaxX;
+	ox0 -= overlap;
+	ix0 -= overlap;
+	ix1 -= overlap;
+	ox1 -= overlap;
+    }
 
-  if (user_oy0 < 0)
-    oy0 = (ScrMaxY - height) / 2;
-  else
-    oy0 = user_oy0;
-  iy0 = oy0 + BOX_BORDER;
-  ty0 = iy0 + FONTH / 2;				// Title of menu
-  ly0 = ty0 + title_height;				// First item of menu
+    if (user_oy0 < 0)
+	oy0 = (ScrMaxY - height) / 2;
+    else
+	oy0 = user_oy0;
+    iy0 = oy0 + BOX_BORDER;
+    ty0 = iy0 + FONTH / 2;	// Title of menu
+    ly0 = ty0 + title_height;	// First item of menu
 
-  oy1 = oy0 + height - 1;
-  iy1 = oy1 - BOX_BORDER;
+    oy1 = oy0 + height - 1;
+    iy1 = oy1 - BOX_BORDER;
 
-  need_geom = false;
+    need_geom = false;
 }
 
 
@@ -755,212 +747,209 @@
  *	- MEN_OTHER: we understood the event and processed it.
  *	- the number of the item that was validated.
  */
-int Menu::process_event (const input_status_t *is)
+int Menu::process_event(const input_status_t * is)
 {
-  return priv->process_event (is);
+    return priv->process_event(is);
 }
 
 
-int Menu_priv::process_event (const input_status_t *is)
+int Menu_priv::process_event(const input_status_t * is)
 {
-  size_t mouse_line;
-  char status;
+    size_t mouse_line;
+    char status;
 
-  if ((int) is->x < ix0 || (int) is->x > ix1 || (int) is->y < ly0)
-    mouse_line = items.size ();
-  else
-  {
-    for (mouse_line = 0; mouse_line < items.size (); mouse_line++)
-      if ((int) is->y >= ly0 + items[mouse_line].y
-	&& (int) is->y < ly0 + items[mouse_line].y + item_height)
-	break;
-  }
+    if ((int) is->x < ix0 || (int) is->x > ix1 || (int) is->y < ly0)
+	mouse_line = items.size();
+    else
+    {
+	for (mouse_line = 0; mouse_line < items.size(); mouse_line++)
+	    if ((int) is->y >= ly0 + items[mouse_line].y
+		&& (int) is->y < ly0 + items[mouse_line].y + item_height)
+		break;
+    }
 
-  status = 'i';
+    status = 'i';
 
-  // Clicking left button on an item: validate it.
-  if (is->key == YE_BUTL_PRESS && mouse_line < items.size ())
-  {
-    line = mouse_line;  // Useless ?
-    status = 'v';
-  }
+    // Clicking left button on an item: validate it.
+    if (is->key == YE_BUTL_PRESS && mouse_line < items.size())
+    {
+	line = mouse_line;	// Useless ?
+	status = 'v';
+    }
 
-  // Moving over the box sets current line.
-  else if (is->key == YE_MOTION && mouse_line < items.size ())
-  {
-    line = mouse_line;
-    status = 'o';
-  }
+    // Moving over the box sets current line.
+    else if (is->key == YE_MOTION && mouse_line < items.size())
+    {
+	line = mouse_line;
+	status = 'o';
+    }
 
-  /* Releasing the button while standing on an item: has a
-     different effect depending on whether we're in pull-down or
-     pop-up mode.
+    /* Releasing the button while standing on an item: has a
+       different effect depending on whether we're in pull-down or
+       pop-up mode.
+
+       In pull-down mode, the button was normally last pressed on
+       the menu bar or on an item of this menu. So the current
+       item is selected upon button release.
 
-     In pull-down mode, the button was normally last pressed on
-     the menu bar or on an item of this menu. So the current
-     item is selected upon button release.
+       In pop-up mode, if the button was pressed, it was most
+       likely to exit a submenu (cf. the "thing type" menu) so we
+       ignore the event. */
+    else if (is->key == YE_BUTL_RELEASE
+	     && mouse_line < items.size() && !(flags & MF_POPUP))
+	status = 'v';
 
-     In pop-up mode, if the button was pressed, it was most
-     likely to exit a submenu (cf. the "thing type" menu) so we
-     ignore the event. */
-  else if (is->key == YE_BUTL_RELEASE
-	&& mouse_line < items.size ()
-	&& ! (flags & MF_POPUP))
-    status = 'v';
+    // [Enter], [Return]: accept selection
+    else if (is->key == YK_RETURN)
+	status = 'v';
 
-  // [Enter], [Return]: accept selection
-  else if (is->key == YK_RETURN)
-    status = 'v';
-
-  // [Esc]: cancel
-  else if (is->key == YK_ESC)
-    status = 'c';
+    // [Esc]: cancel
+    else if (is->key == YK_ESC)
+	status = 'c';
 
-  // [Up]: select previous line
-  else if (is->key == YK_UP)
-  {
-    if (line > 0)
-      line--;
-    else
-      line = items.size () - 1;
-    status = 'o';
-  }
+    // [Up]: select previous line
+    else if (is->key == YK_UP)
+    {
+	if (line > 0)
+	    line--;
+	else
+	    line = items.size() - 1;
+	status = 'o';
+    }
 
-  // [Down]: select next line
-  else if (is->key == YK_DOWN)
-  {
-    if (line < items.size () - 1)
-      line++;
-    else
-      line = 0;
-    status = 'o';
-  }
+    // [Down]: select next line
+    else if (is->key == YK_DOWN)
+    {
+	if (line < items.size() - 1)
+	    line++;
+	else
+	    line = 0;
+	status = 'o';
+    }
+
+    // [Home]: select first line
+    else if (is->key == YK_HOME)
+    {
+	line = 0;
+	status = 'o';
+    }
 
-  // [Home]: select first line
-  else if (is->key == YK_HOME)
-  {
-    line = 0;
-    status = 'o';
-  }
+    // [End]: select last line
+    else if (is->key == YK_END)
+    {
+	line = items.size() - 1;
+	status = 'o';
+    }
 
-  // [End]: select last line
-  else if (is->key == YK_END)
-  {
-    line = items.size () - 1;
-    status = 'o';
-  }
+    // [Pgup]: select line - 5
+    else if (is->key == YK_PU)
+    {
+	if (line >= 5)
+	    line -= 5;
+	else
+	    line = 0;
+	status = 'o';
+    }
 
-  // [Pgup]: select line - 5
-  else if (is->key == YK_PU)
-  {
-    if (line >= 5)
-      line -= 5;
-    else
-      line = 0;
-    status = 'o';
-  }
+    // [Pgdn]: select line + 5
+    else if (is->key == YK_PD)
+    {
+	if (line + 5 < items.size())
+	    line += 5;
+	else
+	    line = items.size() - 1;
+	status = 'o';
+    }
 
-  // [Pgdn]: select line + 5
-  else if (is->key == YK_PD)
-  {
-    if (line + 5 < items.size ())
-      line += 5;
-    else
-      line = items.size () - 1;
-    status = 'o';
-  }
+    // [1]-[9]: select items 0 through 8
+    else if ((flags & MF_NUMS)
+	     && is->key < YK_ && within(dectoi(is->key), 1, items.size()))
+    {
+	line = dectoi(is->key) - 1;
+	status = 'o';
+	send_event(YK_RETURN);
+    }
 
-  // [1]-[9]: select items 0 through 8
-  else if ((flags & MF_NUMS)
-    && is->key < YK_
-    && within (dectoi (is->key), 1, items.size ()))
-  {
-    line = dectoi (is->key) - 1;
-    status = 'o';
-    send_event (YK_RETURN);
-  }
+    // [a]-[z]: select items 9 through 34
+    else if ((flags & MF_NUMS)
+	     && is->key < YK_
+	     && islower(is->key) && within(b36toi(is->key), 10, items.size()))
+    {
+	line = b36toi(is->key) - 1;
+	status = 'o';
+	send_event(YK_RETURN);
+    }
 
-  // [a]-[z]: select items 9 through 34
-  else if ((flags & MF_NUMS)
-    && is->key < YK_
-    && islower (is->key)
-    && within (b36toi (is->key), 10, items.size ()))
-  {
-    line = b36toi (is->key) - 1;
-    status = 'o';
-    send_event (YK_RETURN);
-  }
+    // [A]-[Z]: select items 35 through 60
+    else if ((flags & MF_NUMS)
+	     && is->key < YK_
+	     && isupper(is->key)
+	     && within(b36toi(is->key) + 26, 36, items.size()))
+    {
+	line = b36toi(is->key) + 25;
+	status = 'o';
+	send_event(YK_RETURN);
+    }
 
-  // [A]-[Z]: select items 35 through 60
-  else if ((flags & MF_NUMS)
-    && is->key < YK_
-    && isupper (is->key)
-    && within (b36toi (is->key) + 26, 36, items.size ()))
-  {
-    line = b36toi (is->key) + 25;
-    status = 'o';
-    send_event (YK_RETURN);
-  }
-
-  // A shortcut ?
-  else
-  {
-    /* First, check the list of tilde shortcuts
-       (only if is->key is a regular key) */
-    if ((flags & MF_TILDE)
-        && ! (flags & MF_NUMS)
-        && is->key == (unsigned char) is->key)
+    // A shortcut ?
+    else
     {
-      for (size_t n = 0; n < items.size (); n++)
-	if (items[n].tilde_key != YK_
-	    && items[n].tilde_key == tolower (is->key))
+	/* First, check the list of tilde shortcuts
+	   (only if is->key is a regular key) */
+	if ((flags & MF_TILDE)
+	    && !(flags & MF_NUMS) && is->key == (unsigned char) is->key)
 	{
-	  line = n;
-	  status = 'o';
-	  send_event (YK_RETURN);
-	  break;
+	    for (size_t n = 0; n < items.size(); n++)
+		if (items[n].tilde_key != YK_
+		    && items[n].tilde_key == tolower(is->key))
+		{
+		    line = n;
+		    status = 'o';
+		    send_event(YK_RETURN);
+		    break;
+		}
+	}
+	/* If no tilde shortcut matched, check the list of shortcut
+	   keys. It's important to do the tilde shortcuts first so
+	   that you can override a shortcut key (normally global)
+	   with a tilde shortcut (normally local). */
+	if (status == 'i' && (flags & MF_SHORTCUT) && !(flags & MF_NUMS))
+	{
+	    for (size_t n = 0; n < items.size(); n++)
+		if (items[n].shortcut_key != YK_
+		    && items[n].shortcut_key == is->key)
+		{
+		    line = n;
+		    status = 'o';
+		    send_event(YK_RETURN);
+		    break;
+		}
 	}
     }
-    /* If no tilde shortcut matched, check the list of shortcut
-       keys. It's important to do the tilde shortcuts first so
-       that you can override a shortcut key (normally global)
-       with a tilde shortcut (normally local). */
-    if (status == 'i' && (flags & MF_SHORTCUT) && ! (flags & MF_NUMS))
-    {
-      for (size_t n = 0; n < items.size (); n++)
-	if (items[n].shortcut_key != YK_
-	    && items[n].shortcut_key == is->key)
-	{
-	  line = n;
-	  status = 'o';
-	  send_event (YK_RETURN);
-	  break;
-	}
-    }
-  }
+
+    // See last_shortcut_key()
+    if (status == 'v')
+	_last_shortcut_key =
+	    (flags & MF_SHORTCUT) ? items[line].shortcut_key : 0;
 
-  // See last_shortcut_key()
-  if (status == 'v')
-    _last_shortcut_key = (flags & MF_SHORTCUT) ? items[line].shortcut_key : 0;
-
-  /* Return
-     - the item# if validated,
-     - MEN_CANCEL if cancelled,
-     - MEN_OTHER or MEN_INVALID if neither. */
-  if (status == 'v')
-    return (int) line;
-  else if (status == 'c')
-    return MEN_CANCEL;
-  else if (status == 'o')
-    return MEN_OTHER;
-  else if (status == 'i')
-    return MEN_INVALID;
-  else
-  {
-    // Can't happen
-    fatal_error ("Menu::process_event: bad status %02Xh", status);
-    return 0;  // To please the compiler
-  }
+    /* Return
+       - the item# if validated,
+       - MEN_CANCEL if cancelled,
+       - MEN_OTHER or MEN_INVALID if neither. */
+    if (status == 'v')
+	return (int) line;
+    else if (status == 'c')
+	return MEN_CANCEL;
+    else if (status == 'o')
+	return MEN_OTHER;
+    else if (status == 'i')
+	return MEN_INVALID;
+    else
+    {
+	// Can't happen
+	fatal_error("Menu::process_event: bad status %02Xh", status);
+	return 0;		// To please the compiler
+    }
 }
 
 
@@ -973,9 +962,9 @@
  *	bindings are implemented in editloop.cc,
  *	get_shortcut_key() should disappear.
  */
-inpev_t Menu::last_shortcut_key ()
+inpev_t Menu::last_shortcut_key()
 {
-  return priv->_last_shortcut_key;
+    return priv->_last_shortcut_key;
 }
 
 
@@ -985,56 +974,54 @@
  *	If necessary, redraw everything from scratch. Else, if
  *	<line> has changed, refresh the highlighted line.
  */
-void Menu::draw ()
+void Menu::draw()
 {
-  priv->draw ();
+    priv->draw();
 }
 
 
-void Menu_priv::draw ()
+void Menu_priv::draw()
 {
-  bool from_scratch = false;
+    bool from_scratch = false;
 
-  if (need_geom)
-    geom ();
+    if (need_geom)
+	geom();
 
-  // Do we need to redraw everything from scratch ?
-  if (visible && ! visible_disp
-    || ox0    != ox0_disp
-    || oy0    != oy0_disp
-    || width  != width_disp
-    || height != height_disp)
-    from_scratch = true;
+    // Do we need to redraw everything from scratch ?
+    if (visible && !visible_disp
+	|| ox0 != ox0_disp
+	|| oy0 != oy0_disp || width != width_disp || height != height_disp)
+	from_scratch = true;
+
+    // Display the static part of the menu
+    if (from_scratch)
+    {
+	DrawScreenBox3D(ox0, oy0, ox1, oy1);
+	set_colour(WINTITLE);
+	if ((flags & MF_POPUP) && title != 0)
+	    DrawScreenString(ix0 + WIDE_HSPACING, ty0, title);
 
-  // Display the static part of the menu
-  if (from_scratch)
-  {
-    DrawScreenBox3D (ox0, oy0, ox1, oy1);
-    set_colour (WINTITLE);
-    if ((flags & MF_POPUP) && title != 0)
-      DrawScreenString (ix0 + WIDE_HSPACING, ty0, title);
-
-    for (size_t l = 0; l < items.size (); l++)
-    {
-      set_colour (WINFG);
-      draw_one_line (l, false);
+	for (size_t l = 0; l < items.size(); l++)
+	{
+	    set_colour(WINFG);
+	    draw_one_line(l, false);
+	}
+	visible_disp = true;
+	ox0_disp = ox0;
+	oy0_disp = oy0;
+	width_disp = width;
+	height_disp = height;
     }
-    visible_disp = true;
-    ox0_disp     = ox0;
-    oy0_disp     = oy0;
-    width_disp   = width;
-    height_disp  = height;
-  }
 
-  // Display the "highlight" bar
-  if (from_scratch || line != line_disp)
-  {
-    if (line_disp < items.size ())
-      draw_one_line (line_disp, false);
-    if (line < items.size ())
-      draw_one_line (line, true);
-    line_disp = line;
-  }
+    // Display the "highlight" bar
+    if (from_scratch || line != line_disp)
+    {
+	if (line_disp < items.size())
+	    draw_one_line(line_disp, false);
+	if (line < items.size())
+	    draw_one_line(line, true);
+	line_disp = line;
+    }
 }
 
 
@@ -1045,154 +1032,156 @@
  *  	option). <highlighted> tells whether the option should
  *  	be drawn highlighted.
  */
-void Menu_priv::draw_one_line (size_t line, bool highlighted)
+void Menu_priv::draw_one_line(size_t line, bool highlighted)
 {
-  const Menu_item& i = items[line];
-  int x      = ix0 + FONTW;
-  int y      = ly0 + i.y;
-  int text_y = y + VSPACE / 2;
+    const Menu_item & i = items[line];
+    int x = ix0 + FONTW;
+    int y = ly0 + i.y;
+    int text_y = y + VSPACE / 2;
 
-  // Separation ?
-  if (i.flags & MIF_SEPAR)
-  {
-    push_colour (WINBG_DARK);
-    short groove_y = y - NARROW_VSPACING - 2 * NARROW_BORDER;
-    DrawScreenLine (ix0, groove_y, ix1, groove_y);
-    set_colour (WINBG_LIGHT);
-    DrawScreenLine (ix0, groove_y + 1, ix1, groove_y + 1);
-    pop_colour ();
-  }
+    // Separation ?
+    if (i.flags & MIF_SEPAR)
+    {
+	push_colour(WINBG_DARK);
+	short groove_y = y - NARROW_VSPACING - 2 * NARROW_BORDER;
+	DrawScreenLine(ix0, groove_y, ix1, groove_y);
+	set_colour(WINBG_LIGHT);
+	DrawScreenLine(ix0, groove_y + 1, ix1, groove_y + 1);
+	pop_colour();
+    }
 
-  // Greyed out ?
-  bool active = true;
-  switch (i.flags & MIF_MACTIVE)
-  {
+    // Greyed out ?
+    bool active = true;
+    switch (i.flags & MIF_MACTIVE)
+    {
     case MIF_NACTIVE:
-      active = true;
-      break;
+	active = true;
+	break;
 
     case MIF_SACTIVE:
-      active = i.active.s;
-      break;
+	active = i.active.s;
+	break;
 
     case MIF_VACTIVE:
-      active = *i.active.v;
-      break;
+	active = *i.active.v;
+	break;
 
     case MIF_FACTIVE:
-      active = i.active.f.f (i.active.f.a);
-      break;
+	active = i.active.f.f(i.active.f.a);
+	break;
 
     default:
-      nf_bug ("Menu::draw_one_line: active %02Xh", i.flags);
-      break;
-  }
-  set_colour (menu_colour[! active][highlighted].bg);
-  DrawScreenBox (ix0, y, ix1, y + item_height - 1);
-  set_colour (menu_colour[! active][highlighted].fg);
-
-  // Tick mark if any
-  if (flags & MF_TICK)
-  {
-    bool have_tick = false;
-    bool ticked    = false;
-    switch (i.flags & MIF_MTICK)
-    {
-      case MIF_NTICK:
-        have_tick = false;
-        break;
-
-      case MIF_STICK:
-	have_tick = true;
-        ticked    = i.tick.s;
-        break;
-
-      case MIF_VTICK:
-        have_tick = true;
-        ticked    = *i.tick.v;
-        break;
-
-      case MIF_FTICK:
-        have_tick = true;
-        ticked    = i.tick.f.f (i.tick.f.a);
-        break;
-
-      default:
-        nf_bug ("Menu::draw_one_line: tick %02Xh", i.flags);
-        break;
-    }
-    if (have_tick)
-    {
-      if (ticked)
-      {
-	unsigned hside = FONTW * 4 / 5;
-	unsigned vside = FONTH * 4 / 5;
-	int x0 = x + (FONTW - hside) / 2;
-	int y0 = y + (FONTH - vside) / 2;
-	DrawScreenLine (x0, y0 + vside / 2, x0 + hside / 2, y0 + vside - 1);
-	DrawScreenLine (x0 + hside / 2, y0 + vside - 1, x0 + hside - 1, y0);
-      }
-      else
-      {
-	unsigned margin = FONTW / 5;
-	DrawScreenLine (x + margin,             y + FONTH / 2,
-			x + FONTW - 1 - margin, y + FONTH / 2);
-      }
+	nf_bug("Menu::draw_one_line: active %02Xh", i.flags);
+	break;
     }
-    x += 2 * FONTW;
-  }
+    set_colour(menu_colour[!active][highlighted].bg);
+    DrawScreenBox(ix0, y, ix1, y + item_height - 1);
+    set_colour(menu_colour[!active][highlighted].fg);
+
+    // Tick mark if any
+    if (flags & MF_TICK)
+    {
+	bool have_tick = false;
+	bool ticked = false;
+	switch (i.flags & MIF_MTICK)
+	{
+	case MIF_NTICK:
+	    have_tick = false;
+	    break;
 
-  // Automatic keys if any
-  if (flags & MF_NUMS)
-  {
-    char c = '\0';
-    if (line <= 8)
-      c = '1' + line;
-    else if (line >= 9 && line < 9 + 26)
-      c = 'a' + line - 9;
-    else if (line >= 9 + 26 && line < 9 + 26 + 26)
-      c = 'A' + line - (9 + 26);
-    if (c != '\0')
-    {
-      push_colour (highlighted ? WINLABEL_HL : WINLABEL);
-      DrawScreenString (x, text_y, "[ ]");
-      pop_colour ();
-      DrawScreenChar (x + FONTW, text_y,         c);
-      DrawScreenChar (x + FONTW, text_y + FONTU, '_');
-    }
-    x += 4 * FONTW;
-  }
+	case MIF_STICK:
+	    have_tick = true;
+	    ticked = i.tick.s;
+	    break;
+
+	case MIF_VTICK:
+	    have_tick = true;
+	    ticked = *i.tick.v;
+	    break;
+
+	case MIF_FTICK:
+	    have_tick = true;
+	    ticked = i.tick.f.f(i.tick.f.a);
+	    break;
 
-  // Text
-  int tilde_index = -1;
-  {
-    const char *str = (flags & MF_MENUDATA) ? (*menudata)[line] : i.str;
-    char *buf = new char[strlen (str) + 1]; 
-    char *d   = buf;
-    for (const char *s = str; *s != '\0'; s++)
-    {
-      if (*s == '~' && tilde_index < 0)
-      {
-	tilde_index = s - str;
-	continue;
-      }
-      *d++ = *s;
+	default:
+	    nf_bug("Menu::draw_one_line: tick %02Xh", i.flags);
+	    break;
+	}
+	if (have_tick)
+	{
+	    if (ticked)
+	    {
+		unsigned hside = FONTW * 4 / 5;
+		unsigned vside = FONTH * 4 / 5;
+		int x0 = x + (FONTW - hside) / 2;
+		int y0 = y + (FONTH - vside) / 2;
+		DrawScreenLine(x0, y0 + vside / 2, x0 + hside / 2,
+			       y0 + vside - 1);
+		DrawScreenLine(x0 + hside / 2, y0 + vside - 1, x0 + hside - 1,
+			       y0);
+	    }
+	    else
+	    {
+		unsigned margin = FONTW / 5;
+		DrawScreenLine(x + margin, y + FONTH / 2,
+			       x + FONTW - 1 - margin, y + FONTH / 2);
+	    }
+	}
+	x += 2 * FONTW;
     }
-    *d = '\0';
-    DrawScreenString (x, text_y, buf);
-    delete[] buf;
-  }
+
+    // Automatic keys if any
+    if (flags & MF_NUMS)
+    {
+	char c = '\0';
+	if (line <= 8)
+	    c = '1' + line;
+	else if (line >= 9 && line < 9 + 26)
+	    c = 'a' + line - 9;
+	else if (line >= 9 + 26 && line < 9 + 26 + 26)
+	    c = 'A' + line - (9 + 26);
+	if (c != '\0')
+	{
+	    push_colour(highlighted ? WINLABEL_HL : WINLABEL);
+	    DrawScreenString(x, text_y, "[ ]");
+	    pop_colour();
+	    DrawScreenChar(x + FONTW, text_y, c);
+	    DrawScreenChar(x + FONTW, text_y + FONTU, '_');
+	}
+	x += 4 * FONTW;
+    }
 
-  // Underscore the tilde shortcut if any
-  if (! (flags & MF_NUMS) && tilde_index >= 0)
-    DrawScreenString (x + tilde_index * FONTW, text_y + FONTU, "_");
+    // Text
+    int tilde_index = -1;
+    {
+	const char *str = (flags & MF_MENUDATA) ? (*menudata)[line] : i.str;
+	char *buf = new char[strlen(str) + 1];
+	char *d = buf;
+	for (const char *s = str; *s != '\0'; s++)
+	{
+	    if (*s == '~' && tilde_index < 0)
+	    {
+		tilde_index = s - str;
+		continue;
+	    }
+	    *d++ = *s;
+	}
+	*d = '\0';
+	DrawScreenString(x, text_y, buf);
+	delete[]buf;
+    }
 
-  // Shortcut key if any
-  if (! (flags & MF_NUMS) && i.shortcut_key != YK_)
-  {
-    const char *s = key_to_string (i.shortcut_key);
-    DrawScreenString (ix1 + 1 - FONTW - strlen (s) * FONTW, text_y, s);
-  }
+    // Underscore the tilde shortcut if any
+    if (!(flags & MF_NUMS) && tilde_index >= 0)
+	DrawScreenString(x + tilde_index * FONTW, text_y + FONTU, "_");
+
+    // Shortcut key if any
+    if (!(flags & MF_NUMS) && i.shortcut_key != YK_)
+    {
+	const char *s = key_to_string(i.shortcut_key);
+	DrawScreenString(ix1 + 1 - FONTW - strlen(s) * FONTW, text_y, s);
+    }
 }
 
 
@@ -1201,66 +1190,65 @@
  */
 
 
-void Menu::undraw ()
+void Menu::undraw()
 {
-  ;  // I can't undraw myself
-}
-
-
-int Menu::can_undraw ()
-{
-  return 0;  // I can't undraw myself
+    ;				// I can't undraw myself
 }
 
 
-int Menu::need_to_clear ()
+int Menu::can_undraw()
 {
-  return ! priv->visible && priv->visible_disp || priv->need_geom;
+    return 0;			// I can't undraw myself
 }
 
 
-void Menu::clear ()
+int Menu::need_to_clear()
 {
-  priv->visible_disp = false;
+    return !priv->visible && priv->visible_disp || priv->need_geom;
 }
 
 
-int Menu::req_width ()
+void Menu::clear()
 {
-  if (priv->need_geom)
-    priv->geom ();
-  return priv->width;
+    priv->visible_disp = false;
 }
 
 
-int Menu::req_height ()
+int Menu::req_width()
 {
-  if (priv->need_geom)
-    priv->geom ();
-  return priv->height;
+    if (priv->need_geom)
+	priv->geom();
+    return priv->width;
 }
 
 
-int Menu::get_x0 ()
+int Menu::req_height()
 {
-  return priv->ox0_disp;
+    if (priv->need_geom)
+	priv->geom();
+    return priv->height;
 }
 
 
-int Menu::get_y0 ()
+int Menu::get_x0()
 {
-  return priv->oy0_disp;
+    return priv->ox0_disp;
 }
 
 
-int Menu::get_x1 ()
+int Menu::get_y0()
 {
-  return priv->ox0_disp + priv->width_disp - 1;
+    return priv->oy0_disp;
 }
 
 
-int Menu::get_y1 ()
+int Menu::get_x1()
 {
-  return priv->oy0_disp + priv->height_disp - 1;
+    return priv->ox0_disp + priv->width_disp - 1;
 }
 
+
+int Menu::get_y1()
+{
+    return priv->oy0_disp + priv->height_disp - 1;
+}
--- a/src/menu.h	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/menu.h	Sat Sep 24 14:16:04 2011 +0300
@@ -27,7 +27,7 @@
 */
 
 
-#ifndef YH_MENUS  /* DO NOT INSERT ANYTHING BEFORE THIS LINE */
+#ifndef YH_MENUS		/* DO NOT INSERT ANYTHING BEFORE THIS LINE */
 #define YH_MENUS
 
 
@@ -36,10 +36,10 @@
 #include "edwidget.h"
 
 
-typedef struct 
+typedef struct
 {
-  acolour_t bg;
-  acolour_t fg;
+    acolour_t bg;
+    acolour_t fg;
 } colour_pair_t;
 
 /* First subscript :  0 = normal, 1 = greyed out
@@ -58,13 +58,13 @@
 
 extern const char *MI_SEPARATION;
 
-typedef void *micbarg_t;		// Argument of callback function
-typedef bool (*micb_t) (micbarg_t);	// Pointer to callback function
+typedef void *micbarg_t;	// Argument of callback function
+typedef bool(*micb_t) (micbarg_t);	// Pointer to callback function
 
 // Values returned by process_event()
-const int MEN_CANCEL  = -1;  // Exit by [Esc]. Caller should destroy the menu.
-const int MEN_OTHER   = -2;  // Got other event and processed it.
-const int MEN_INVALID = -3;  // Got invalid event. Caller should process it.
+const int MEN_CANCEL = -1;	// Exit by [Esc]. Caller should destroy the menu.
+const int MEN_OTHER = -2;	// Got other event and processed it.
+const int MEN_INVALID = -3;	// Got invalid event. Caller should process it.
 
 
 class Menu_data;
@@ -74,48 +74,48 @@
 /*
  *	Menu - a menu class
  */
-class Menu : public edwidget_c
+class Menu:public edwidget_c
 {
-  public :
-    // Ctors
-    Menu (const char *title, ...);
-    Menu (const char *title, va_list argp);
-    Menu (const char *title, al_llist_t *list, const char *(*getstr)(void *));
-    Menu (const char *title, const Menu_data& menudata);
-    ~Menu ();
+    public:
+	// Ctors
+    Menu(const char *title, ...);
+      Menu(const char *title, va_list argp);
+      Menu(const char *title, al_llist_t * list,
+	   const char *(*getstr) (void *));
+      Menu(const char *title, const Menu_data & menudata);
+     ~Menu();
 
     // Configuration
-    void set_coords (int x, int y);
-    void set_title (const char *title);
-    void set_item_no (int item_no);
-    void set_popup (bool popup);
-    void set_force_numbers (bool force_numbers);
-    void set_visible (bool visible);
-    void set_ticked (size_t item_no, bool ticked);
-    void set_active (size_t item_no, bool active);
+    void set_coords(int x, int y);
+    void set_title(const char *title);
+    void set_item_no(int item_no);
+    void set_popup(bool popup);
+    void set_force_numbers(bool force_numbers);
+    void set_visible(bool visible);
+    void set_ticked(size_t item_no, bool ticked);
+    void set_active(size_t item_no, bool active);
 
     // Event processing
-    int process_event (const input_status_t *is);
-    inpev_t last_shortcut_key ();
+    int process_event(const input_status_t * is);
+    inpev_t last_shortcut_key();
 
     // Widget functions
-    void draw ();
-    void undraw ();
-    int can_undraw ();
-    int need_to_clear ();
-    void clear ();
-    int req_width ();
-    int req_height ();
-    int get_x0 ();
-    int get_y0 ();
-    int get_x1 ();
-    int get_y1 ();
+    void draw();
+    void undraw();
+    int can_undraw();
+    int need_to_clear();
+    void clear();
+    int req_width();
+    int req_height();
+    int get_x0();
+    int get_y0();
+    int get_x1();
+    int get_y1();
 
-  private :
-    Menu (const Menu&);			// Too lazy to implement it
-    Menu& operator= (const Menu&);	// Too lazy to implement it
+      private: Menu(const Menu &);	// Too lazy to implement it
+      Menu & operator=(const Menu &);	// Too lazy to implement it
     Menu_priv *priv;
 };
 
 
-#endif  /* DO NOT ADD ANYTHING AFTER THIS LINE */
+#endif /* DO NOT ADD ANYTHING AFTER THIS LINE */
--- a/src/menubar.cc	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/menubar.cc	Sat Sep 24 14:16:04 2011 +0300
@@ -51,25 +51,25 @@
 /*
  *	menubar_c
  */
-menubar_c::menubar_c ()
+menubar_c::menubar_c()
 {
-stale_coords          = 1;
-nitems                = 0;
-stale_x0_x1           = 1;
-spacing               = FONTW;
-bar_visible           = 1;
-bar_visible_disp      = 0;
-highlighted_no        = -1;
-highlighted_no_disp   = -1;
-pulled_down_no        = -1;
-pulled_down_no_disp   = -1;
-pulled_down_menu      = 0;
-pulled_down_menu_disp = 0;
+    stale_coords = 1;
+    nitems = 0;
+    stale_x0_x1 = 1;
+    spacing = FONTW;
+    bar_visible = 1;
+    bar_visible_disp = 0;
+    highlighted_no = -1;
+    highlighted_no_disp = -1;
+    pulled_down_no = -1;
+    pulled_down_no_disp = -1;
+    pulled_down_menu = 0;
+    pulled_down_menu_disp = 0;
 #if 0
-for (size_t n = 0; n < MAX_ITEMS; n++)
-   {
-   item_menu[n] = 0;
-   }
+    for (size_t n = 0; n < MAX_ITEMS; n++)
+    {
+	item_menu[n] = 0;
+    }
 #endif
 }
 
@@ -83,29 +83,30 @@
  *	(<scrx1>, <scry1>) are the coordinates
  *	of the bottom right corner of the screen/window.
  */
-void menubar_c::compute_menubar_coords (int scrx0, int scry0, int scrx1, int scry1)
+void menubar_c::compute_menubar_coords(int scrx0, int scry0, int scrx1,
+				       int scry1)
 {
 // Just to prevent the compiler from emitting an
 // annoying warning about that parameter being unused.
-scry1 = 0;
+    scry1 = 0;
 
-menubar_out_x0  = scrx0;
-menubar_in_x0   = menubar_out_x0 + BOX_BORDER;
-menubar_text_x0 = menubar_in_x0;
+    menubar_out_x0 = scrx0;
+    menubar_in_x0 = menubar_out_x0 + BOX_BORDER;
+    menubar_text_x0 = menubar_in_x0;
 
-menubar_out_x1  = scrx1;
-menubar_in_x1   = menubar_out_x1 - BOX_BORDER;
-menubar_text_x1 = menubar_in_x1;
+    menubar_out_x1 = scrx1;
+    menubar_in_x1 = menubar_out_x1 - BOX_BORDER;
+    menubar_text_x1 = menubar_in_x1;
 
-menubar_out_y0  = scry0;
-menubar_in_y0   = menubar_out_y0  + BOX_BORDER;
-menubar_text_y0 = menubar_in_y0   + NARROW_VSPACING;
-menubar_text_y1 = menubar_text_y0 + FONTH - 1;
-menubar_in_y1   = menubar_text_y1 + NARROW_VSPACING;
-menubar_out_y1  = menubar_in_y1   + BOX_BORDER;
+    menubar_out_y0 = scry0;
+    menubar_in_y0 = menubar_out_y0 + BOX_BORDER;
+    menubar_text_y0 = menubar_in_y0 + NARROW_VSPACING;
+    menubar_text_y1 = menubar_text_y0 + FONTH - 1;
+    menubar_in_y1 = menubar_text_y1 + NARROW_VSPACING;
+    menubar_out_y1 = menubar_in_y1 + BOX_BORDER;
 
-stale_coords = 0;
-stale_x0_x1 = 1;
+    stale_coords = 0;
+    stale_x0_x1 = 1;
 }
 
 
@@ -116,20 +117,20 @@
  *	right aligned on the menu bar.
  *	Returns the number of the newly created item.
  */
-int menubar_c::add_item (const char *text, int shortcut_index,
-   int right_aligned, Menu *menu)
+int menubar_c::add_item(const char *text, int shortcut_index,
+			int right_aligned, Menu * menu)
 {
-if (nitems >= MAX_ITEMS)
-   fatal_error ("Too many items on menu bar");
-if (shortcut_index < 0 || shortcut_index >= (int) strlen (text))
-   fatal_error ("add_menubar_item: shortcut_index out of range");
-item_text[nitems]           = text;
-item_shortcut_index[nitems] = shortcut_index;
-item_right_aligned[nitems]  = right_aligned;
-item_menu[nitems]           = menu;
-nitems++;
-stale_x0_x1 = 1;
-return nitems - 1;
+    if (nitems >= MAX_ITEMS)
+	fatal_error("Too many items on menu bar");
+    if (shortcut_index < 0 || shortcut_index >= (int) strlen(text))
+	fatal_error("add_menubar_item: shortcut_index out of range");
+    item_text[nitems] = text;
+    item_shortcut_index[nitems] = shortcut_index;
+    item_right_aligned[nitems] = right_aligned;
+    item_menu[nitems] = menu;
+    nitems++;
+    stale_x0_x1 = 1;
+    return nitems - 1;
 }
 
 
@@ -137,15 +138,15 @@
  *	set_menu
  *	Change the menu for an existing menu bar item.
  */
-void menubar_c::set_menu (int number, Menu *menu)
+void menubar_c::set_menu(int number, Menu * menu)
 {
-if (number >= nitems)
-   fatal_error ("set_menu: bad mbi#");
-item_menu[number] = menu;
+    if (number >= nitems)
+	fatal_error("set_menu: bad mbi#");
+    item_menu[number] = menu;
 
 // So that need_to_clear() knows something has changed
-if (number == pulled_down_no)
-   pulled_down_menu = menu;
+    if (number == pulled_down_no)
+	pulled_down_menu = menu;
 }
 
 
@@ -153,11 +154,11 @@
  *	get_menu
  *	Return a pointer on the menu for an existing menu bar item.
  */
-Menu *menubar_c::get_menu (int number)
+Menu *menubar_c::get_menu(int number)
 {
-if (number >= nitems)
-   fatal_error ("set_menu: bad mbi#");
-return item_menu[number];
+    if (number >= nitems)
+	fatal_error("set_menu: bad mbi#");
+    return item_menu[number];
 }
 
 
@@ -166,17 +167,17 @@
  *	Highlight the menu bar item number <number>.
  *	Use <number> < 0 to clear the highlighting.
  */
-void menubar_c::highlight (int number)
+void menubar_c::highlight(int number)
 {
-highlighted_no = number;
-if (pulled_down_no >= 0)
-   {
-   pulled_down_no = number;
-   if (number >= 0)
-      pulled_down_menu = item_menu[number];
-   else
-      pulled_down_menu = 0;
-   }
+    highlighted_no = number;
+    if (pulled_down_no >= 0)
+    {
+	pulled_down_no = number;
+	if (number >= 0)
+	    pulled_down_menu = item_menu[number];
+	else
+	    pulled_down_menu = 0;
+    }
 }
 
 
@@ -185,9 +186,9 @@
  *	Return the number of the menu bar item that is highlighted
  *	or < 0 if none.
  */
-int menubar_c::highlighted ()
+int menubar_c::highlighted()
 {
-return highlighted_no;
+    return highlighted_no;
 }
 
 
@@ -196,22 +197,22 @@
  *	Pull down the menu under the menu bar item number <number>.
  *	Use <number> < 0 to "unroll".
  */
-void menubar_c::pull_down (int number)
+void menubar_c::pull_down(int number)
 {
-if (number >= 0 && number != pulled_down_no)
-   item_menu[number]->set_item_no (0);
+    if (number >= 0 && number != pulled_down_no)
+	item_menu[number]->set_item_no(0);
 
-pulled_down_no = number;
+    pulled_down_no = number;
 
-if (number >= 0)
-   {
-   pulled_down_menu = item_menu[number];
-   // Pulling down a menu implies highlighting
-   // the corresponding item on the menu bar.
-   highlight (number);
-   }
-else
-   pulled_down_menu = 0;
+    if (number >= 0)
+    {
+	pulled_down_menu = item_menu[number];
+	// Pulling down a menu implies highlighting
+	// the corresponding item on the menu bar.
+	highlight(number);
+    }
+    else
+	pulled_down_menu = 0;
 }
 
 
@@ -220,26 +221,26 @@
  *	Return the number of the menu bar item that is pulled down
  *	or < 0 if none.
  */
-int menubar_c::pulled_down ()
+int menubar_c::pulled_down()
 {
-return pulled_down_no;
+    return pulled_down_no;
 }
 
 
 /*
  *	clear
  */
-void menubar_c::clear ()
+void menubar_c::clear()
 {
 //for (int n = 0; n < nitems; n++)
 //   item_menu[n]->clear ();
 
-if (pulled_down_menu_disp)
-   pulled_down_menu_disp->clear ();
-bar_visible_disp      = 0;
-highlighted_no_disp   = -1;
-pulled_down_no_disp   = -1;
-pulled_down_menu_disp = 0;
+    if (pulled_down_menu_disp)
+	pulled_down_menu_disp->clear();
+    bar_visible_disp = 0;
+    highlighted_no_disp = -1;
+    pulled_down_no_disp = -1;
+    pulled_down_menu_disp = 0;
 }
 
 
@@ -247,58 +248,61 @@
  *	draw
  *	Draw the menu bar according to its current state.
  */
-void menubar_c::draw ()
+void menubar_c::draw()
 {
 // Draw the menu bar itself
-if (bar_visible && ! bar_visible_disp
-   || highlighted_no != highlighted_no_disp)
-   {
-   if (stale_x0_x1)
-      compute_x0_x1 ();
-   push_colour (menu_colour[0][0].bg);  /* 1 */
-   DrawScreenBox3D (0, 0, ScrMaxX, menubar_out_y1);
-   set_colour (menu_colour[0][0].fg);
-   for (int n = 0; n < nitems; n++)
-      {
-      if (n == highlighted_no)
-	 {
-	 push_colour (menu_colour[0][1].bg);  /* 2 */
-	 DrawScreenBox (item_x0[n], menubar_in_y0, item_x1[n], menubar_in_y1);
-	 set_colour (menu_colour[0][1].fg);
-	 }
-      DrawScreenString (item_x0[n] + spacing, menubar_text_y0, item_text[n]);
-      DrawScreenString (item_x0[n] + spacing + item_shortcut_index[n] * FONTW,
-		      menubar_text_y0 + FONTU, "_");
-      if (n == highlighted_no)
-	 pop_colour ();  /* 2 */
-      }
-   pop_colour ();  /* 1 */
-   bar_visible_disp    = 1;
-   highlighted_no_disp = highlighted_no;
-   }
+    if (bar_visible && !bar_visible_disp
+	|| highlighted_no != highlighted_no_disp)
+    {
+	if (stale_x0_x1)
+	    compute_x0_x1();
+	push_colour(menu_colour[0][0].bg);	/* 1 */
+	DrawScreenBox3D(0, 0, ScrMaxX, menubar_out_y1);
+	set_colour(menu_colour[0][0].fg);
+	for (int n = 0; n < nitems; n++)
+	{
+	    if (n == highlighted_no)
+	    {
+		push_colour(menu_colour[0][1].bg);	/* 2 */
+		DrawScreenBox(item_x0[n], menubar_in_y0, item_x1[n],
+			      menubar_in_y1);
+		set_colour(menu_colour[0][1].fg);
+	    }
+	    DrawScreenString(item_x0[n] + spacing, menubar_text_y0,
+			     item_text[n]);
+	    DrawScreenString(item_x0[n] + spacing +
+			     item_shortcut_index[n] * FONTW,
+			     menubar_text_y0 + FONTU, "_");
+	    if (n == highlighted_no)
+		pop_colour();	/* 2 */
+	}
+	pop_colour();		/* 1 */
+	bar_visible_disp = 1;
+	highlighted_no_disp = highlighted_no;
+    }
 
 // If there is a menu that used to be visible
 // but isn't anymore, let it be aware of it.
-if (pulled_down_menu_disp && pulled_down_menu != pulled_down_menu_disp)
-   {
-   pulled_down_menu_disp->clear ();
-   pulled_down_menu_disp->set_visible (0);
-   }
+    if (pulled_down_menu_disp && pulled_down_menu != pulled_down_menu_disp)
+    {
+	pulled_down_menu_disp->clear();
+	pulled_down_menu_disp->set_visible(0);
+    }
 
 // Draw the pulled down menu (if any)
-if (pulled_down_menu)
-   {
-   int x, y;
-   menubar_item_coords (pulled_down_no, &x, &y);
-   pulled_down_menu->set_popup         (0);
-   pulled_down_menu->set_force_numbers (0);
-   pulled_down_menu->set_coords        (x, y);
-   pulled_down_menu->set_visible       (1);
-   pulled_down_menu->draw              ();
-   }
+    if (pulled_down_menu)
+    {
+	int x, y;
+	menubar_item_coords(pulled_down_no, &x, &y);
+	pulled_down_menu->set_popup(0);
+	pulled_down_menu->set_force_numbers(0);
+	pulled_down_menu->set_coords(x, y);
+	pulled_down_menu->set_visible(1);
+	pulled_down_menu->draw();
+    }
 
-pulled_down_no_disp   = pulled_down_no;
-pulled_down_menu_disp = pulled_down_menu;
+    pulled_down_no_disp = pulled_down_no;
+    pulled_down_menu_disp = pulled_down_menu;
 }
 
 
@@ -308,19 +312,19 @@
  *	be pulled down if the user clicked at screen coords (x,y).
  *	Returns -1 if none.
  */
-int menubar_c::is_on_menubar_item (int x, int y)
+int menubar_c::is_on_menubar_item(int x, int y)
 {
-if (stale_coords)
-   fatal_error ("Called iomi before cc");
-if (x < menubar_in_x0 || x > menubar_in_x1
- || y < menubar_in_y0 || y > menubar_in_y1)
-   return -1;
-if (stale_x0_x1)
-   compute_x0_x1 ();
-for (int n = 0; n < nitems; n++)
-   if (x >= item_x0[n] && x <= item_x1[n])
-      return n;
-return -1;
+    if (stale_coords)
+	fatal_error("Called iomi before cc");
+    if (x < menubar_in_x0 || x > menubar_in_x1
+	|| y < menubar_in_y0 || y > menubar_in_y1)
+	return -1;
+    if (stale_x0_x1)
+	compute_x0_x1();
+    for (int n = 0; n < nitems; n++)
+	if (x >= item_x0[n] && x <= item_x1[n])
+	    return n;
+    return -1;
 }
 
 
@@ -333,16 +337,16 @@
  *	abscissa as a menubar item, it probably means that the
  *	user is reaching for the menus so don't scroll.
  */
-int menubar_c::is_under_menubar_item (int scrx)
+int menubar_c::is_under_menubar_item(int scrx)
 {
-if (stale_coords)
-   fatal_error ("Called iumi before cc");
-if (stale_x0_x1)
-   compute_x0_x1 ();
-for (int n = 0; n < nitems; n++)
-   if (scrx >= item_x0[n] && scrx <= item_x1[n])
-      return n;
-return -1;
+    if (stale_coords)
+	fatal_error("Called iumi before cc");
+    if (stale_x0_x1)
+	compute_x0_x1();
+    for (int n = 0; n < nitems; n++)
+	if (scrx >= item_x0[n] && scrx <= item_x1[n])
+	    return n;
+    return -1;
 }
 
 
@@ -350,39 +354,39 @@
  *	compute_x0_x1
  *	Fill in item_x0 and item_x1.
  */
-void menubar_c::compute_x0_x1 ()
+void menubar_c::compute_x0_x1()
 {
-int x_left;
-int x_right;
-int n;
+    int x_left;
+    int x_right;
+    int n;
 
-if (stale_coords)
-   fatal_error ("Called compute_x0_x1 before compute_coords");
-x_left  = menubar_text_x0;
-x_right = menubar_text_x1;
-for (n = 0; n < nitems; n++)
-   {
-   int item_width = 2 * spacing + strlen (item_text[n]) * FONTW;
+    if (stale_coords)
+	fatal_error("Called compute_x0_x1 before compute_coords");
+    x_left = menubar_text_x0;
+    x_right = menubar_text_x1;
+    for (n = 0; n < nitems; n++)
+    {
+	int item_width = 2 * spacing + strlen(item_text[n]) * FONTW;
 
-   /* This item is right-aligned ?
-      Place it to the left of the last right-aligned item. */
-   if (item_right_aligned[n])
-      {
-      item_x1[n] = x_right;
-      x_right -= item_width;
-      item_x0[n] = x_right + 1;
-      }
+	/* This item is right-aligned ?
+	   Place it to the left of the last right-aligned item. */
+	if (item_right_aligned[n])
+	{
+	    item_x1[n] = x_right;
+	    x_right -= item_width;
+	    item_x0[n] = x_right + 1;
+	}
 
-   /* It's left-aligned.
-      Place it to the right of the last left-aligned item. */
-   else
-      {
-      item_x0[n] = x_left;
-      x_left += item_width;
-      item_x1[n] = x_left - 1;
-      }
-   }
-stale_x0_x1 = 0;
+	/* It's left-aligned.
+	   Place it to the right of the last left-aligned item. */
+	else
+	{
+	    item_x0[n] = x_left;
+	    x_left += item_width;
+	    item_x1[n] = x_left - 1;
+	}
+    }
+    stale_x0_x1 = 0;
 }
 
 
@@ -393,17 +397,14 @@
  *	This function will be removed when menus are pulled down
  *	by menubar.cc itself.
  */
-void menubar_c::menubar_item_coords (int item_no, int *x, int *y)
+void menubar_c::menubar_item_coords(int item_no, int *x, int *y)
 {
-if (item_no < 0 || item_no >= nitems)
-   fatal_error ("menubar_item_coords passed bad item no. %d", item_no);
-if (stale_coords)
-   fatal_error ("Called menubar_item_coords before compute_coords");
-if (stale_x0_x1)
-   compute_x0_x1 ();
-*x = item_x0[item_no];
-*y = menubar_out_y1 + 1;
+    if (item_no < 0 || item_no >= nitems)
+	fatal_error("menubar_item_coords passed bad item no. %d", item_no);
+    if (stale_coords)
+	fatal_error("Called menubar_item_coords before compute_coords");
+    if (stale_x0_x1)
+	compute_x0_x1();
+    *x = item_x0[item_no];
+    *y = menubar_out_y1 + 1;
 }
-
-
-
--- a/src/menubar.h	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/menubar.h	Sat Sep 24 14:16:04 2011 +0300
@@ -48,77 +48,79 @@
 static const int MAX_ITEMS = 10;
 
 
-class menubar_c : public edwidget_c
-   {
-   public :
-      menubar_c ();
+class menubar_c:public edwidget_c
+{
+    public: menubar_c();
 
-      int add_item (const char *text, int shortcut_index, int right_aligned,
-         Menu *menu);
-      void set_menu (int number, Menu *menu);
-      Menu *get_menu (int number);
-      void compute_menubar_coords (int scrx0, int scrx1, int scry0, int scry1);
-      void highlight (int number);
-      void pull_down (int number);
-      int highlighted ();
-      int pulled_down ();
-      int is_on_menubar_item (int scrx, int scry);
-      int is_under_menubar_item (int scrx);
-      void menubar_item_coords (int item_no, int *x, int *y);
+    int add_item(const char *text, int shortcut_index, int right_aligned,
+		 Menu * menu);
+    void set_menu(int number, Menu * menu);
+    Menu *get_menu(int number);
+    void compute_menubar_coords(int scrx0, int scrx1, int scry0, int scry1);
+    void highlight(int number);
+    void pull_down(int number);
+    int highlighted();
+    int pulled_down();
+    int is_on_menubar_item(int scrx, int scry);
+    int is_under_menubar_item(int scrx);
+    void menubar_item_coords(int item_no, int *x, int *y);
 
-      /*
-       *	widget
-       */
-      void draw ();
-      void undraw () { }  // I can't undraw myself
-      int can_undraw () { return 0; }  // I can't undraw myself
+    /*
+     *        widget
+     */
+    void draw();
+    void undraw()
+    {
+    }				// I can't undraw myself
+    int can_undraw()
+    {
+	return 0;
+    }				// I can't undraw myself
 
-      int need_to_clear ()
-         {
-         return bar_visible_disp && ! bar_visible
-            || pulled_down_no_disp && ! pulled_down_no
-            || pulled_down_menu_disp != pulled_down_menu;
-         }
+    int need_to_clear()
+    {
+	return bar_visible_disp && !bar_visible
+	    || pulled_down_no_disp && !pulled_down_no
+	    || pulled_down_menu_disp != pulled_down_menu;
+    }
 
-      void clear ();
-
-   private :
-      void compute_x0_x1 ();
+    void clear();
 
-      int spacing;          		// Horizontal spacing around item name
+  private:
+    void compute_x0_x1();
+
+    int spacing;		// Horizontal spacing around item name
 
-      int stale_coords;			// Should menubar_* be recalculated ?
-      int menubar_out_x0;		// Edge of the menu bar, includ. border
-      int menubar_out_x1;
-      int menubar_out_y0;
-      int menubar_out_y1;
-      int menubar_in_x0;		// Edge of the menu bar, exclud. border
-      int menubar_in_x1;
-      int menubar_in_y0;
-      int menubar_in_y1;
-      int menubar_text_x0;		// Edge of the text area of the menu bar
-      int menubar_text_x1;
-      int menubar_text_y0;
-      int menubar_text_y1;
+    int stale_coords;		// Should menubar_* be recalculated ?
+    int menubar_out_x0;		// Edge of the menu bar, includ. border
+    int menubar_out_x1;
+    int menubar_out_y0;
+    int menubar_out_y1;
+    int menubar_in_x0;		// Edge of the menu bar, exclud. border
+    int menubar_in_x1;
+    int menubar_in_y0;
+    int menubar_in_y1;
+    int menubar_text_x0;	// Edge of the text area of the menu bar
+    int menubar_text_x1;
+    int menubar_text_y0;
+    int menubar_text_y1;
 
-      int nitems;			// Number of items
-      const char *item_text[MAX_ITEMS];	// Definition of items
-      int item_shortcut_index[MAX_ITEMS];
-      int item_right_aligned[MAX_ITEMS];
-      Menu *item_menu[MAX_ITEMS];
-       
-      int stale_x0_x1;         		// Should item_x? be recalculated ?
-      int item_x0[MAX_ITEMS];		// Left edge of items, includ. spacing
-      int item_x1[MAX_ITEMS];		// Right edge of items, includ. spacing
+    int nitems;			// Number of items
+    const char *item_text[MAX_ITEMS];	// Definition of items
+    int item_shortcut_index[MAX_ITEMS];
+    int item_right_aligned[MAX_ITEMS];
+    Menu *item_menu[MAX_ITEMS];
+
+    int stale_x0_x1;		// Should item_x? be recalculated ?
+    int item_x0[MAX_ITEMS];	// Left edge of items, includ. spacing
+    int item_x1[MAX_ITEMS];	// Right edge of items, includ. spacing
 
-      int bar_visible;			// Should the bar be visible ?
-      int bar_visible_disp;		// Is the bar actually visible ?
-      int highlighted_no;		// # of the item that should be h.l.
-      int highlighted_no_disp;		// # of the item that is actually h.l.
-      int pulled_down_no;		// # of menu that should be p.d.
-      int pulled_down_no_disp;		// # of menu that is actually p.d.
-      Menu *pulled_down_menu;		// Menu that should be p.d.
-      Menu *pulled_down_menu_disp;	// Menu that is actually p.d.
-   };
-
-
+    int bar_visible;		// Should the bar be visible ?
+    int bar_visible_disp;	// Is the bar actually visible ?
+    int highlighted_no;		// # of the item that should be h.l.
+    int highlighted_no_disp;	// # of the item that is actually h.l.
+    int pulled_down_no;		// # of menu that should be p.d.
+    int pulled_down_no_disp;	// # of menu that is actually p.d.
+    Menu *pulled_down_menu;	// Menu that should be p.d.
+    Menu *pulled_down_menu_disp;	// Menu that is actually p.d.
+};
--- a/src/menudata.h	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/menudata.h	Sat Sep 24 14:16:04 2011 +0300
@@ -27,16 +27,15 @@
 */
 
 
-#ifndef YH_MENUDATA  /* DO NOT INSERT ANYTHING BEFORE THIS LINE */
+#ifndef YH_MENUDATA		/* DO NOT INSERT ANYTHING BEFORE THIS LINE */
 #define YH_MENUDATA
 
 
 class Menu_data
 {
-  public :
-    virtual size_t nitems () const = 0;
+    public: virtual size_t nitems() const = 0;
     virtual const char *operator[] (size_t n) const = 0;
 };
 
 
-#endif  /* DO NOT ADD ANYTHING AFTER THIS LINE */
+#endif /* DO NOT ADD ANYTHING AFTER THIS LINE */
--- a/src/mkpalette.cc	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/mkpalette.cc	Sat Sep 24 14:16:04 2011 +0300
@@ -42,73 +42,67 @@
  *	palette in the PLAYPAL entry.
  *	Return 0 on success, non-zero on failure.
  */
-int make_gimp_palette (int playpalnum, const char *filename)
+int make_gimp_palette(int playpalnum, const char *filename)
 {
-  int     rc        = 0;
-  MDirPtr dir;
-  u8	 *dpal      = 0;
-  FILE	 *output_fp = 0;
+    int rc = 0;
+    MDirPtr dir;
+    u8 *dpal = 0;
+    FILE *output_fp = 0;
 
-  const char *lump_name = "PLAYPAL";
-  dir = FindMasterDir (MasterDir, lump_name);
-  if (dir == 0)
-  {
-    warn ("%s: lump not found\n",lump_name);
-    return 1;
-  }
+    const char *lump_name = "PLAYPAL";
+    dir = FindMasterDir(MasterDir, lump_name);
+    if (dir == 0)
+    {
+	warn("%s: lump not found\n", lump_name);
+	return 1;
+    }
 
-  int playpal_count = dir->dir.size / (3 * DOOM_COLOURS);
-  if (playpalnum < 0 || playpalnum >= playpal_count)
-  {
-    warn ("playpalnum %d out of range (0-%d), using #0 instead\n",
-      playpalnum, playpal_count - 1);
-    playpalnum = 0;
-  }
+    int playpal_count = dir->dir.size / (3 * DOOM_COLOURS);
+    if (playpalnum < 0 || playpalnum >= playpal_count)
+    {
+	warn("playpalnum %d out of range (0-%d), using #0 instead\n",
+	     playpalnum, playpal_count - 1);
+	playpalnum = 0;
+    }
 
-  output_fp = fopen (filename, "w");
-  if (output_fp == 0)
-  {
-    warn ("%s: %s\n", filename, strerror (errno));
-    return 1;
-  }
-  fprintf (output_fp,
-     "GIMP Palette\n"
-     "# Generated by Yadex %s\n", yadex_version);
+    output_fp = fopen(filename, "w");
+    if (output_fp == 0)
+    {
+	warn("%s: %s\n", filename, strerror(errno));
+	return 1;
+    }
+    fprintf(output_fp,
+	    "GIMP Palette\n" "# Generated by Yadex %s\n", yadex_version);
 
-  dpal = (u8 *) GetMemory (3 * DOOM_COLOURS);
-  const Wad_file *wf = dir->wadfile;
-  wf->seek (dir->dir.start + (long) playpalnum * 3 * DOOM_COLOURS);
-  if (wf->error ())
-  {
-    err ("%s: seek error", lump_name);
-    rc = 1;
-    goto byebye;
-  }
-  wf->read_bytes (dpal, 3 * DOOM_COLOURS);
-  if (wf->error ())
-  {
-    err ("%s: read error", lump_name);
-    rc = 1;
-    goto byebye;
-  }
-  for (size_t n = 0; n < DOOM_COLOURS; n++)
-    fprintf (output_fp, "%3d %3d %3d  Index = %d (%02Xh)   RGB = %d, %d, %d\n",
-      dpal[3 * n],
-      dpal[3 * n + 1],
-      dpal[3 * n + 2],
-      n,
-      n,
-      dpal[3 * n],
-      dpal[3 * n + 1],
-      dpal[3 * n + 2]);
+    dpal = (u8 *) GetMemory(3 * DOOM_COLOURS);
+    const Wad_file *wf = dir->wadfile;
+    wf->seek(dir->dir.start + (long) playpalnum * 3 * DOOM_COLOURS);
+    if (wf->error())
+    {
+	err("%s: seek error", lump_name);
+	rc = 1;
+	goto byebye;
+    }
+    wf->read_bytes(dpal, 3 * DOOM_COLOURS);
+    if (wf->error())
+    {
+	err("%s: read error", lump_name);
+	rc = 1;
+	goto byebye;
+    }
+    for (size_t n = 0; n < DOOM_COLOURS; n++)
+	fprintf(output_fp,
+		"%3d %3d %3d  Index = %d (%02Xh)   RGB = %d, %d, %d\n",
+		dpal[3 * n], dpal[3 * n + 1], dpal[3 * n + 2], n, n,
+		dpal[3 * n], dpal[3 * n + 1], dpal[3 * n + 2]);
 
   byebye:
-  if (dpal != 0)
-    FreeMemory (dpal);
-  if (output_fp != 0)
-    if (fclose (output_fp))
-      return 1;
-  return rc;
+    if (dpal != 0)
+	FreeMemory(dpal);
+    if (output_fp != 0)
+	if (fclose(output_fp))
+	    return 1;
+    return rc;
 }
 
 
@@ -118,93 +112,93 @@
  *	colours in the palette.
  *	Return 0 on success, non-zero on failure.
  */
-int make_palette_ppm (int playpalnum, const char *filename)
+int make_palette_ppm(int playpalnum, const char *filename)
 {
-  int     rc        = 0;
-  MDirPtr dir;
-  u8	 *dpal      = 0;
-  FILE	 *output_fp = 0;
+    int rc = 0;
+    MDirPtr dir;
+    u8 *dpal = 0;
+    FILE *output_fp = 0;
 
-  const char *lump_name = "PLAYPAL";
-  dir = FindMasterDir (MasterDir, lump_name);
-  if (dir == 0)
-  {
-    warn ("%s: lump not found\n", lump_name);
-    return 1;
-  }
+    const char *lump_name = "PLAYPAL";
+    dir = FindMasterDir(MasterDir, lump_name);
+    if (dir == 0)
+    {
+	warn("%s: lump not found\n", lump_name);
+	return 1;
+    }
 
-  int playpal_count = dir->dir.size / (3 * DOOM_COLOURS);
-  if (playpalnum < 0 || playpalnum >= playpal_count)
-  {
-    warn ("playpalnum %d out of range (0-%d), using #0 instead\n",
-      playpalnum, playpal_count - 1);
-    playpalnum = 0;
-  }
+    int playpal_count = dir->dir.size / (3 * DOOM_COLOURS);
+    if (playpalnum < 0 || playpalnum >= playpal_count)
+    {
+	warn("playpalnum %d out of range (0-%d), using #0 instead\n",
+	     playpalnum, playpal_count - 1);
+	playpalnum = 0;
+    }
 
-  output_fp = fopen (filename, "wb");
-  if (output_fp == 0)
-  {
-    warn ("%s: %s\n", filename, strerror (errno));
-    return 1;
-  }
+    output_fp = fopen(filename, "wb");
+    if (output_fp == 0)
+    {
+	warn("%s: %s\n", filename, strerror(errno));
+	return 1;
+    }
 
-  const int width = 128;
-  const int height = 128;
-  const int columns = 16;
+    const int width = 128;
+    const int height = 128;
+    const int columns = 16;
 
-  fputs ("P6", output_fp);
-  fnewline (output_fp);
-  fprintf (output_fp, "# Generated by Yadex %s", yadex_version);
-  fnewline (output_fp);
-  fprintf (output_fp, "%d %d", width, height);
-  fnewline (output_fp);
-  fputs ("255\n", output_fp);  // Always \n (must be a single character)
+    fputs("P6", output_fp);
+    fnewline(output_fp);
+    fprintf(output_fp, "# Generated by Yadex %s", yadex_version);
+    fnewline(output_fp);
+    fprintf(output_fp, "%d %d", width, height);
+    fnewline(output_fp);
+    fputs("255\n", output_fp);	// Always \n (must be a single character)
 
-  int rect_w = width / columns;
-  int rect_h = height / (DOOM_COLOURS / columns);
+    int rect_w = width / columns;
+    int rect_h = height / (DOOM_COLOURS / columns);
 
-  dpal = (u8 *) GetMemory (3 * DOOM_COLOURS);
-  const Wad_file *wf = dir->wadfile;
-  wf->seek (dir->dir.start + (long) playpalnum * 3 * DOOM_COLOURS);
-  if (wf->error ())
-  {
-    err ("%s: seek error", lump_name);
-    rc = 1;
-    goto byebye;
-  }
-  wf->read_bytes (dpal, 3 * DOOM_COLOURS);
-  if (wf->error ())
-  {
-    err ("%s: read error", lump_name);
-    rc = 1;
-    goto byebye;
-  }
-  for (size_t n = 0; n < DOOM_COLOURS; n += columns)
-    for (int subrow = 0; subrow < rect_h; subrow++)
-      for (int c = 0; c < columns; c++)
-	for (int subcol = 0; subcol < rect_w; subcol++)
-	{
-	  if (subrow == 0 && subcol == 0)
-	  {
-	    putc (0, output_fp);
-	    putc (0, output_fp);
-	    putc (0, output_fp);
-	  }
-	  else
-	  {
-	    putc (dpal[3 * (n + c)],     output_fp);
-	    putc (dpal[3 * (n + c) + 1], output_fp);
-	    putc (dpal[3 * (n + c) + 2], output_fp);
-	  }
-	}
+    dpal = (u8 *) GetMemory(3 * DOOM_COLOURS);
+    const Wad_file *wf = dir->wadfile;
+    wf->seek(dir->dir.start + (long) playpalnum * 3 * DOOM_COLOURS);
+    if (wf->error())
+    {
+	err("%s: seek error", lump_name);
+	rc = 1;
+	goto byebye;
+    }
+    wf->read_bytes(dpal, 3 * DOOM_COLOURS);
+    if (wf->error())
+    {
+	err("%s: read error", lump_name);
+	rc = 1;
+	goto byebye;
+    }
+    for (size_t n = 0; n < DOOM_COLOURS; n += columns)
+	for (int subrow = 0; subrow < rect_h; subrow++)
+	    for (int c = 0; c < columns; c++)
+		for (int subcol = 0; subcol < rect_w; subcol++)
+		{
+		    if (subrow == 0 && subcol == 0)
+		    {
+			putc(0, output_fp);
+			putc(0, output_fp);
+			putc(0, output_fp);
+		    }
+		    else
+		    {
+			putc(dpal[3 * (n + c)], output_fp);
+			putc(dpal[3 * (n + c) + 1], output_fp);
+			putc(dpal[3 * (n + c) + 2], output_fp);
+		    }
+		}
 
   byebye:
-  if (dpal != 0)
-    FreeMemory (dpal);
-  if (output_fp != 0)
-    if (fclose (output_fp))
-      return 1;
-  return rc;
+    if (dpal != 0)
+	FreeMemory(dpal);
+    if (output_fp != 0)
+	if (fclose(output_fp))
+	    return 1;
+    return rc;
 }
 
 
@@ -213,78 +207,76 @@
  *	Make a wide PPM containing all the colours in the palette
  */
 
-int make_palette_ppm_2 (int playpalnum, const char *filename)
+int make_palette_ppm_2(int playpalnum, const char *filename)
 {
-  int     rc        = 0;
-  MDirPtr dir;
-  u8	 *dpal      = 0;
-  FILE	 *output_fp = 0;
-
-  const char *lump_name = "PLAYPAL";
-  dir = FindMasterDir (MasterDir, lump_name);
-  if (dir == 0)
-  {
-    warn ("%s: lump not found", lump_name);
-    return 1;
-  }
-
-  int playpal_count = dir->dir.size / (3 * DOOM_COLOURS);
-  if (playpalnum < 0 || playpalnum >= playpal_count)
-  {
-    warn ("playpalnum %d out of range (0-%d), using #0 instead",
-      playpalnum, playpal_count - 1);
-    playpalnum = 0;
-  }
-
-  output_fp = fopen (filename, "wb");
-  if (output_fp == 0)
-  {
-    warn ("%s: %s\n", filename, strerror (errno));
-    return 1;
-  }
+    int rc = 0;
+    MDirPtr dir;
+    u8 *dpal = 0;
+    FILE *output_fp = 0;
 
-  const int width = DOOM_COLOURS;
-  const int height = DOOM_COLOURS;
-
-  fputs ("P6", output_fp);
-  fnewline (output_fp);
-  fprintf (output_fp, "# Generated by Yadex %s", yadex_version);
-  fnewline (output_fp);
-  fprintf (output_fp, "%d %d", width, height);
-  fnewline (output_fp);
-  fputs ("255\n", output_fp);  // Always \n (must be a single character)
+    const char *lump_name = "PLAYPAL";
+    dir = FindMasterDir(MasterDir, lump_name);
+    if (dir == 0)
+    {
+	warn("%s: lump not found", lump_name);
+	return 1;
+    }
 
-  dpal = (u8 *) GetMemory (3 * DOOM_COLOURS);
-  const Wad_file *wf = dir->wadfile;
-  wf->seek (dir->dir.start + (long) playpalnum * 3 * DOOM_COLOURS);
-  if (wf->error ())
-  {
-    err ("%s: seek error", lump_name);
-    rc = 1;
-    goto byebye;
-  }
-  wf->read_bytes (dpal, 3 * DOOM_COLOURS);
-  if (wf->error ())
-  {
-    err ("%s: read error", lump_name);
-    rc = 1;
-    goto byebye;
-  }
-  for (int l = 0; l < height; l++)
-    for (int c = 0; c < width; c++)
+    int playpal_count = dir->dir.size / (3 * DOOM_COLOURS);
+    if (playpalnum < 0 || playpalnum >= playpal_count)
     {
-      putc (dpal[3 * ((c + l) % DOOM_COLOURS)    ], output_fp);
-      putc (dpal[3 * ((c + l) % DOOM_COLOURS) + 1], output_fp);
-      putc (dpal[3 * ((c + l) % DOOM_COLOURS) + 2], output_fp);
+	warn("playpalnum %d out of range (0-%d), using #0 instead",
+	     playpalnum, playpal_count - 1);
+	playpalnum = 0;
+    }
+
+    output_fp = fopen(filename, "wb");
+    if (output_fp == 0)
+    {
+	warn("%s: %s\n", filename, strerror(errno));
+	return 1;
     }
 
+    const int width = DOOM_COLOURS;
+    const int height = DOOM_COLOURS;
+
+    fputs("P6", output_fp);
+    fnewline(output_fp);
+    fprintf(output_fp, "# Generated by Yadex %s", yadex_version);
+    fnewline(output_fp);
+    fprintf(output_fp, "%d %d", width, height);
+    fnewline(output_fp);
+    fputs("255\n", output_fp);	// Always \n (must be a single character)
+
+    dpal = (u8 *) GetMemory(3 * DOOM_COLOURS);
+    const Wad_file *wf = dir->wadfile;
+    wf->seek(dir->dir.start + (long) playpalnum * 3 * DOOM_COLOURS);
+    if (wf->error())
+    {
+	err("%s: seek error", lump_name);
+	rc = 1;
+	goto byebye;
+    }
+    wf->read_bytes(dpal, 3 * DOOM_COLOURS);
+    if (wf->error())
+    {
+	err("%s: read error", lump_name);
+	rc = 1;
+	goto byebye;
+    }
+    for (int l = 0; l < height; l++)
+	for (int c = 0; c < width; c++)
+	{
+	    putc(dpal[3 * ((c + l) % DOOM_COLOURS)], output_fp);
+	    putc(dpal[3 * ((c + l) % DOOM_COLOURS) + 1], output_fp);
+	    putc(dpal[3 * ((c + l) % DOOM_COLOURS) + 2], output_fp);
+	}
+
   byebye:
-  if (dpal != 0)
-    FreeMemory (dpal);
-  if (output_fp != 0)
-    if (fclose (output_fp))
-      return 1;
-  return rc;
+    if (dpal != 0)
+	FreeMemory(dpal);
+    if (output_fp != 0)
+	if (fclose(output_fp))
+	    return 1;
+    return rc;
 }
-
-
--- a/src/mkpalette.h	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/mkpalette.h	Sat Sep 24 14:16:04 2011 +0300
@@ -5,8 +5,6 @@
  */
 
 
-int make_gimp_palette (int playpalnum, const char *filename);
-int make_palette_ppm (int playpalnum, const char *filename);
-int make_palette_ppm_2 (int playpalnum, const char *filename);
-
-
+int make_gimp_palette(int playpalnum, const char *filename);
+int make_palette_ppm(int playpalnum, const char *filename);
+int make_palette_ppm_2(int playpalnum, const char *filename);
--- a/src/modpopup.h	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/modpopup.h	Sat Sep 24 14:16:04 2011 +0300
@@ -33,90 +33,87 @@
 #include "menu.h"
 
 
-class modpopup_c : public edwidget_c
+class modpopup_c:public edwidget_c
 {
-  public :
-
-    /*
-     *	EditorLoop() side methods
-     */
-    modpopup_c ()
+    public:
+	/*
+	 *  EditorLoop() side methods
+	 */
+    modpopup_c()
     {
-      menu = 0;
-      menu_disp = 0;
+	menu = 0;
+	menu_disp = 0;
     }
 
-    void set (Menu *menu, int force_numbers)
+    void set(Menu * menu, int force_numbers)
     {
-      if (menu_disp)
-	menu_disp->set_visible (0);
-      this->menu = menu;
-      menu->set_popup         (1);
-      menu->set_force_numbers (force_numbers);
-      menu->set_coords        (-1, -1);
-      menu->set_item_no       (0);
-      menu->set_visible       (1);
+	if (menu_disp)
+	    menu_disp->set_visible(0);
+	this->menu = menu;
+	menu->set_popup(1);
+	menu->set_force_numbers(force_numbers);
+	menu->set_coords(-1, -1);
+	menu->set_item_no(0);
+	menu->set_visible(1);
     }
 
-    void unset ()
+    void unset()
     {
-      if (menu_disp)
-	menu_disp->set_visible (0);
-      menu = 0;
+	if (menu_disp)
+	    menu_disp->set_visible(0);
+	menu = 0;
     }
 
-    Menu *get ()
+    Menu *get()
     {
-      return menu;
+	return menu;
     }
 
     /*
-     *	edisplay_c side methods
+     *  edisplay_c side methods
      */
-    void draw ()
+    void draw()
     {
-      if (menu)
-      {
-	menu->draw ();
-	menu_disp = menu;
-      }
+	if (menu)
+	{
+	    menu->draw();
+	    menu_disp = menu;
+	}
     }
 
-    void undraw ()
+    void undraw()
     {
-      if (menu_disp)
+	if (menu_disp)
 	{
-	  menu_disp->undraw ();
-	  //menu_disp = 0;
+	    menu_disp->undraw();
+	    //menu_disp = 0;
 	}
     }
 
-    int can_undraw ()
+    int can_undraw()
     {
-      if (menu_disp)
-	return menu_disp->can_undraw ();
-      else
-	return 1;
+	if (menu_disp)
+	    return menu_disp->can_undraw();
+	else
+	    return 1;
     }
 
-    int need_to_clear ()
+    int need_to_clear()
     {
-      if (menu_disp)
-	return menu_disp->need_to_clear ();
-      else
-	return 0;
+	if (menu_disp)
+	    return menu_disp->need_to_clear();
+	else
+	    return 0;
     }
 
-    void clear ()
+    void clear()
     {
-      if (menu_disp)
-	menu_disp->clear ();
+	if (menu_disp)
+	    menu_disp->clear();
     }
 
-  private :
+  private:
 
-    Menu *menu;
+    Menu * menu;
     Menu *menu_disp;
 };
-
-
--- a/src/names.cc	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/names.cc	Sat Sep 24 14:16:04 2011 +0300
@@ -35,22 +35,32 @@
 /*
    get the name of an object type
 */
-const char *GetObjectTypeName (int objtype)
+const char *GetObjectTypeName(int objtype)
 {
-switch (objtype)
-   {
-   case OBJ_THINGS:   return "thing";
-   case OBJ_LINEDEFS: return "linedef";
-   case OBJ_SIDEDEFS: return "sidedef";
-   case OBJ_VERTICES: return "vertex";
-   case OBJ_SEGS:     return "segment";
-   case OBJ_SSECTORS: return "ssector";
-   case OBJ_NODES:    return "node";
-   case OBJ_SECTORS:  return "sector";
-   case OBJ_REJECT:   return "reject";
-   case OBJ_BLOCKMAP: return "blockmap";
-   }
-return "< Bug! >";
+    switch (objtype)
+    {
+    case OBJ_THINGS:
+	return "thing";
+    case OBJ_LINEDEFS:
+	return "linedef";
+    case OBJ_SIDEDEFS:
+	return "sidedef";
+    case OBJ_VERTICES:
+	return "vertex";
+    case OBJ_SEGS:
+	return "segment";
+    case OBJ_SSECTORS:
+	return "ssector";
+    case OBJ_NODES:
+	return "node";
+    case OBJ_SECTORS:
+	return "sector";
+    case OBJ_REJECT:
+	return "reject";
+    case OBJ_BLOCKMAP:
+	return "blockmap";
+    }
+    return "< Bug! >";
 }
 
 
@@ -58,20 +68,27 @@
 /*
    what are we editing?
 */
-const char *GetEditModeName (int objtype)
+const char *GetEditModeName(int objtype)
 {
-switch (objtype)
-   {
-   case OBJ_THINGS:   return "Things";
-   case OBJ_LINEDEFS:
-   case OBJ_SIDEDEFS: return "LD & SD";
-   case OBJ_VERTICES: return "Vertices";
-   case OBJ_SEGS:     return "Segments";
-   case OBJ_SSECTORS: return "Seg-Sectors";
-   case OBJ_NODES:    return "Nodes";
-   case OBJ_SECTORS:  return "Sectors";
-   }
-return "< Bug! >";
+    switch (objtype)
+    {
+    case OBJ_THINGS:
+	return "Things";
+    case OBJ_LINEDEFS:
+    case OBJ_SIDEDEFS:
+	return "LD & SD";
+    case OBJ_VERTICES:
+	return "Vertices";
+    case OBJ_SEGS:
+	return "Segments";
+    case OBJ_SSECTORS:
+	return "Seg-Sectors";
+    case OBJ_NODES:
+	return "Nodes";
+    case OBJ_SECTORS:
+	return "Sectors";
+    }
+    return "< Bug! >";
 }
 
 
@@ -80,14 +97,14 @@
    get a short (16 char.) description of the type of a linedef
 */
 
-const char *GetLineDefTypeName (int type)
+const char *GetLineDefTypeName(int type)
 {
-if (CUR_LDTDEF != NULL && CUR_LDTDEF->number == type)
-  return CUR_LDTDEF->shortdesc;
-for (al_lrewind (ldtdef); ! al_leol (ldtdef); al_lstep (ldtdef))
-  if (CUR_LDTDEF->number == type)
-    return CUR_LDTDEF->shortdesc;
-return "??  UNKNOWN";
+    if (CUR_LDTDEF != NULL && CUR_LDTDEF->number == type)
+	return CUR_LDTDEF->shortdesc;
+    for (al_lrewind(ldtdef); !al_leol(ldtdef); al_lstep(ldtdef))
+	if (CUR_LDTDEF->number == type)
+	    return CUR_LDTDEF->shortdesc;
+    return "??  UNKNOWN";
 }
 
 
@@ -95,71 +112,71 @@
    get a short description of the flags of a linedef
 */
 
-const char *GetLineDefFlagsName (int flags)
+const char *GetLineDefFlagsName(int flags)
 {
-static char buf[20];
+    static char buf[20];
 // "P" is a Boom extension ("pass through")
 // "T" is for Strife ("translucent")
-const char *flag_chars = "???T??PANBSLU2MI";
-int n;
+    const char *flag_chars = "???T??PANBSLU2MI";
+    int n;
 
-char *p = buf;
-for (n = 0; n < 16; n++)
-   {
-   if (n != 0 && n % 4 == 0)
-      *p++ = ' ';
-   if (flags & (0x8000u >> n))
-      *p++ = flag_chars[n];
-   else
-      *p++ = '-';
-   }
-*p = '\0';
-return buf;
+    char *p = buf;
+    for (n = 0; n < 16; n++)
+    {
+	if (n != 0 && n % 4 == 0)
+	    *p++ = ' ';
+	if (flags & (0x8000u >> n))
+	    *p++ = flag_chars[n];
+	else
+	    *p++ = '-';
+    }
+    *p = '\0';
+    return buf;
 
 #if 0
-static char temp[20];
-if (flags & 0x0100)
-   strcpy (temp, "A"); /* Already on the map (Ma) */
-else
-   strcpy (temp, "-");
-if (flags & 0x80)
-   strcat (temp, "V"); /* Invisible on the map (In) */
-else
-   strcat (temp, "-");
-if (flags & 0x40)
-   strcat (temp, "B"); /* Blocks sound (So) */
-else
-   strcat (temp, "-");
-if (flags & 0x20)
-   strcat (temp, "S"); /* Secret (normal on the map) (Se) */
-else
-   strcat (temp, "-");
-if (flags & 0x10)
-   strcat (temp, "L"); /* Lower texture offset changed (Lo) */
-else
-   strcat (temp, "-");
-if (flags & 0x08)
-   strcat (temp, "U"); /* Upper texture offset changed (Up) */
-else
-   strcat (temp, "-");
-if (flags & 0x04)
-   strcat (temp, "2"); /* Two-sided (2S) */
-else
-   strcat (temp, "-");
-if (flags & 0x02)
-   strcat (temp, "M"); /* Monsters can't cross this line (Mo) */
-else
-   strcat (temp, "-");
-if (flags & 0x01)
-   strcat (temp, "I"); /* Impassible (Im) */
-else
-   strcat (temp, "-");
-if (strlen (temp) > 13)
-{
-   temp[13] = '|';
-   temp[14] = '\0';
-}
-return temp;
+    static char temp[20];
+    if (flags & 0x0100)
+	strcpy(temp, "A");	/* Already on the map (Ma) */
+    else
+	strcpy(temp, "-");
+    if (flags & 0x80)
+	strcat(temp, "V");	/* Invisible on the map (In) */
+    else
+	strcat(temp, "-");
+    if (flags & 0x40)
+	strcat(temp, "B");	/* Blocks sound (So) */
+    else
+	strcat(temp, "-");
+    if (flags & 0x20)
+	strcat(temp, "S");	/* Secret (normal on the map) (Se) */
+    else
+	strcat(temp, "-");
+    if (flags & 0x10)
+	strcat(temp, "L");	/* Lower texture offset changed (Lo) */
+    else
+	strcat(temp, "-");
+    if (flags & 0x08)
+	strcat(temp, "U");	/* Upper texture offset changed (Up) */
+    else
+	strcat(temp, "-");
+    if (flags & 0x04)
+	strcat(temp, "2");	/* Two-sided (2S) */
+    else
+	strcat(temp, "-");
+    if (flags & 0x02)
+	strcat(temp, "M");	/* Monsters can't cross this line (Mo) */
+    else
+	strcat(temp, "-");
+    if (flags & 0x01)
+	strcat(temp, "I");	/* Impassible (Im) */
+    else
+	strcat(temp, "-");
+    if (strlen(temp) > 13)
+    {
+	temp[13] = '|';
+	temp[14] = '\0';
+    }
+    return temp;
 #endif
 }
 
@@ -169,20 +186,31 @@
    get a long description of one linedef flag
 */
 
-const char *GetLineDefFlagsLongName (int flags)
+const char *GetLineDefFlagsLongName(int flags)
 {
-if (flags & 0x1000) return "Translucent [Strife]";
-if (flags & 0x200)  return "Pass-through [Boom]";
-if (flags & 0x100)  return "Always shown on the map";
-if (flags & 0x80)   return "Never shown on the map";
-if (flags & 0x40)   return "Blocks sound";
-if (flags & 0x20)   return "Secret (shown as normal on the map)";
-if (flags & 0x10)   return "Lower texture is \"unpegged\"";
-if (flags & 0x08)   return "Upper texture is \"unpegged\"";
-if (flags & 0x04)   return "Two-sided (may be transparent)";
-if (flags & 0x02)   return "Monsters cannot cross this line";
-if (flags & 0x01)   return "Impassible";
-return "UNKNOWN";
+    if (flags & 0x1000)
+	return "Translucent [Strife]";
+    if (flags & 0x200)
+	return "Pass-through [Boom]";
+    if (flags & 0x100)
+	return "Always shown on the map";
+    if (flags & 0x80)
+	return "Never shown on the map";
+    if (flags & 0x40)
+	return "Blocks sound";
+    if (flags & 0x20)
+	return "Secret (shown as normal on the map)";
+    if (flags & 0x10)
+	return "Lower texture is \"unpegged\"";
+    if (flags & 0x08)
+	return "Upper texture is \"unpegged\"";
+    if (flags & 0x04)
+	return "Two-sided (may be transparent)";
+    if (flags & 0x02)
+	return "Monsters cannot cross this line";
+    if (flags & 0x01)
+	return "Impassible";
+    return "UNKNOWN";
 }
 
 
@@ -191,20 +219,20 @@
    get a short (14 char.) description of the type of a sector
 */
 
-const char *GetSectorTypeName (int type)
+const char *GetSectorTypeName(int type)
 {
 /* KLUDGE: To avoid the last element which is bogus */
-if (al_ltell (stdef) == al_lcount (stdef) - 1)
-  al_lrewind (stdef);
+    if (al_ltell(stdef) == al_lcount(stdef) - 1)
+	al_lrewind(stdef);
 
-if (CUR_STDEF != NULL && CUR_STDEF->number == type)
-  return CUR_STDEF->shortdesc;
-for (al_lrewind (stdef); ! al_leol (stdef); al_lstep (stdef))
-  if (CUR_STDEF->number == type)
-    return CUR_STDEF->shortdesc;
-static char buf[30];
-sprintf (buf, "UNKNOWN (%d)", type);
-return buf;
+    if (CUR_STDEF != NULL && CUR_STDEF->number == type)
+	return CUR_STDEF->shortdesc;
+    for (al_lrewind(stdef); !al_leol(stdef); al_lstep(stdef))
+	if (CUR_STDEF->number == type)
+	    return CUR_STDEF->shortdesc;
+    static char buf[30];
+    sprintf(buf, "UNKNOWN (%d)", type);
+    return buf;
 }
 
 
@@ -213,20 +241,18 @@
    get a long description of the type of a sector
 */
 
-const char *GetSectorTypeLongName (int type)
+const char *GetSectorTypeLongName(int type)
 {
 /* KLUDGE: To avoid the last element which is bogus */
-if (al_ltell (stdef) == al_lcount (stdef) - 1)
-  al_lrewind (stdef);
+    if (al_ltell(stdef) == al_lcount(stdef) - 1)
+	al_lrewind(stdef);
 
-if (CUR_STDEF != NULL && CUR_STDEF->number == type)
-  return CUR_STDEF->longdesc;
-for (al_lrewind (stdef); ! al_leol (stdef); al_lstep (stdef))
-  if (CUR_STDEF->number == type)
-    return CUR_STDEF->longdesc;
-static char buf[30];
-sprintf (buf, "UNKNOWN (%d)", type);
-return buf;
+    if (CUR_STDEF != NULL && CUR_STDEF->number == type)
+	return CUR_STDEF->longdesc;
+    for (al_lrewind(stdef); !al_leol(stdef); al_lstep(stdef))
+	if (CUR_STDEF->number == type)
+	    return CUR_STDEF->longdesc;
+    static char buf[30];
+    sprintf(buf, "UNKNOWN (%d)", type);
+    return buf;
 }
-
-
--- a/src/nop.cc	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/nop.cc	Sat Sep 24 14:16:04 2011 +0300
@@ -30,8 +30,7 @@
 #include "yadex.h"
 
 
-void nop (...)
+void nop(...)
 {
-;
+    ;
 }
-
--- a/src/objects.cc	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/objects.cc	Sat Sep 24 14:16:04 2011 +0300
@@ -43,14 +43,14 @@
 /*
    highlight the selected objects
 */
-void HighlightSelection (int objtype, SelPtr list) /* SWAP! */
+void HighlightSelection(int objtype, SelPtr list)	/* SWAP! */
 {
-SelPtr cur;
+    SelPtr cur;
 
-if (! list)
-   return;
-for (cur = list; cur; cur = cur->next)
-   HighlightObject (objtype, cur->objnum, GREEN);
+    if (!list)
+	return;
+    for (cur = list; cur; cur = cur->next)
+	HighlightObject(objtype, cur->objnum, GREEN);
 }
 
 
@@ -58,122 +58,122 @@
 /*
    get the number of objects of a given type minus one
 */
-obj_no_t GetMaxObjectNum (int objtype)
+obj_no_t GetMaxObjectNum(int objtype)
 {
-switch (objtype)
-   {
-   case OBJ_THINGS:
-      return NumThings - 1;
-   case OBJ_LINEDEFS:
-      return NumLineDefs - 1;
-   case OBJ_SIDEDEFS:
-      return NumSideDefs - 1;
-   case OBJ_VERTICES:
-      return NumVertices - 1;
-   case OBJ_SECTORS:
-      return NumSectors - 1;
-   }
-return -1;
+    switch (objtype)
+    {
+    case OBJ_THINGS:
+	return NumThings - 1;
+    case OBJ_LINEDEFS:
+	return NumLineDefs - 1;
+    case OBJ_SIDEDEFS:
+	return NumSideDefs - 1;
+    case OBJ_VERTICES:
+	return NumVertices - 1;
+    case OBJ_SECTORS:
+	return NumSectors - 1;
+    }
+    return -1;
 }
 
 
 /*
    highlight the selected object
 */
-void HighlightObject (int objtype, int objnum, int colour) /* SWAP! */
+void HighlightObject(int objtype, int objnum, int colour)	/* SWAP! */
 {
-int  n, m;
+    int n, m;
 
 /* use XOR mode : drawing any line twice erases it */
-SetDrawingMode (1);
-set_colour (colour);
-switch (objtype)
-   {
-   case OBJ_THINGS:
-      m = (get_thing_radius (Things[objnum].type) * 3) / 2;
-      DrawMapLine (Things[objnum].xpos - m, Things[objnum].ypos - m,
-		   Things[objnum].xpos - m, Things[objnum].ypos + m);
-      DrawMapLine (Things[objnum].xpos - m, Things[objnum].ypos + m,
-		   Things[objnum].xpos + m, Things[objnum].ypos + m);
-      DrawMapLine (Things[objnum].xpos + m, Things[objnum].ypos + m,
-		   Things[objnum].xpos + m, Things[objnum].ypos - m);
-      DrawMapLine (Things[objnum].xpos + m, Things[objnum].ypos - m,
-		   Things[objnum].xpos - m, Things[objnum].ypos - m);
-      DrawMapArrow (Things[objnum].xpos, Things[objnum].ypos,
-		    Things[objnum].angle * 182);
-      break;
+    SetDrawingMode(1);
+    set_colour(colour);
+    switch (objtype)
+    {
+    case OBJ_THINGS:
+	m = (get_thing_radius(Things[objnum].type) * 3) / 2;
+	DrawMapLine(Things[objnum].xpos - m, Things[objnum].ypos - m,
+		    Things[objnum].xpos - m, Things[objnum].ypos + m);
+	DrawMapLine(Things[objnum].xpos - m, Things[objnum].ypos + m,
+		    Things[objnum].xpos + m, Things[objnum].ypos + m);
+	DrawMapLine(Things[objnum].xpos + m, Things[objnum].ypos + m,
+		    Things[objnum].xpos + m, Things[objnum].ypos - m);
+	DrawMapLine(Things[objnum].xpos + m, Things[objnum].ypos - m,
+		    Things[objnum].xpos - m, Things[objnum].ypos - m);
+	DrawMapArrow(Things[objnum].xpos, Things[objnum].ypos,
+		     Things[objnum].angle * 182);
+	break;
 
-   case OBJ_LINEDEFS:
-      n = (Vertices[LineDefs[objnum].start].x
-	 + Vertices[LineDefs[objnum].end].x) / 2;
-      m = (Vertices[LineDefs[objnum].start].y
-	 + Vertices[LineDefs[objnum].end].y) / 2;
-      DrawMapLine (n, m, n + (Vertices[LineDefs[objnum].end].y
-			    - Vertices[LineDefs[objnum].start].y) / 3,
-			 m + (Vertices[LineDefs[objnum].start].x
-			    - Vertices[LineDefs[objnum].end].x) / 3);
-      SetLineThickness (1);
-      DrawMapVector (Vertices[LineDefs[objnum].start].x,
-		     Vertices[LineDefs[objnum].start].y,
-		     Vertices[LineDefs[objnum].end].x,
-		     Vertices[LineDefs[objnum].end].y);
-      if (colour != LIGHTRED && LineDefs[objnum].tag > 0)
-	 {
-	 for (m = 0; m < NumSectors; m++)
-	    if (Sectors[m].tag == LineDefs[objnum].tag)
-	       HighlightObject (OBJ_SECTORS, m, LIGHTRED);
-	 }
-      SetLineThickness (0);
-      break;
+    case OBJ_LINEDEFS:
+	n = (Vertices[LineDefs[objnum].start].x
+	     + Vertices[LineDefs[objnum].end].x) / 2;
+	m = (Vertices[LineDefs[objnum].start].y
+	     + Vertices[LineDefs[objnum].end].y) / 2;
+	DrawMapLine(n, m, n + (Vertices[LineDefs[objnum].end].y
+			       - Vertices[LineDefs[objnum].start].y) / 3,
+		    m + (Vertices[LineDefs[objnum].start].x
+			 - Vertices[LineDefs[objnum].end].x) / 3);
+	SetLineThickness(1);
+	DrawMapVector(Vertices[LineDefs[objnum].start].x,
+		      Vertices[LineDefs[objnum].start].y,
+		      Vertices[LineDefs[objnum].end].x,
+		      Vertices[LineDefs[objnum].end].y);
+	if (colour != LIGHTRED && LineDefs[objnum].tag > 0)
+	{
+	    for (m = 0; m < NumSectors; m++)
+		if (Sectors[m].tag == LineDefs[objnum].tag)
+		    HighlightObject(OBJ_SECTORS, m, LIGHTRED);
+	}
+	SetLineThickness(0);
+	break;
 
-   case OBJ_VERTICES:
-      {
-      int r = vertex_radius (Scale) * 3 / 2;
-      int scrx0 = SCREENX (Vertices[objnum].x) - r;
-      int scrx9 = SCREENX (Vertices[objnum].x) + r;
-      int scry0 = SCREENY (Vertices[objnum].y) - r;
-      int scry9 = SCREENY (Vertices[objnum].y) + r;
-      DrawScreenLine (scrx0, scry0, scrx9, scry0);
-      DrawScreenLine (scrx9, scry0, scrx9, scry9);
-      DrawScreenLine (scrx9, scry9, scrx0, scry9);
-      DrawScreenLine (scrx0, scry9, scrx0, scry0);
-      }
-      break;
+    case OBJ_VERTICES:
+	{
+	    int r = vertex_radius(Scale) * 3 / 2;
+	    int scrx0 = SCREENX(Vertices[objnum].x) - r;
+	    int scrx9 = SCREENX(Vertices[objnum].x) + r;
+	    int scry0 = SCREENY(Vertices[objnum].y) - r;
+	    int scry9 = SCREENY(Vertices[objnum].y) + r;
+	    DrawScreenLine(scrx0, scry0, scrx9, scry0);
+	    DrawScreenLine(scrx9, scry0, scrx9, scry9);
+	    DrawScreenLine(scrx9, scry9, scrx0, scry9);
+	    DrawScreenLine(scrx0, scry9, scrx0, scry0);
+	}
+	break;
 
-   case OBJ_SECTORS:
-      {
-      SetLineThickness (1);
-      const int mapx0 = MAPX (0);
-      const int mapy0 = MAPY (ScrMaxY);
-      const int mapx1 = MAPX (ScrMaxX);
-      const int mapy1 = MAPY (0);
-      for (n = 0; n < NumLineDefs; n++)
-	 if (LineDefs[n].sidedef1 != -1
-	     && SideDefs[LineDefs[n].sidedef1].sector == objnum
-	  || LineDefs[n].sidedef2 != -1
-	     && SideDefs[LineDefs[n].sidedef2].sector == objnum)
-	 {
-	    const struct Vertex *v1 = Vertices + LineDefs[n].start;
-	    const struct Vertex *v2 = Vertices + LineDefs[n].end;
-	    if (v1->x < mapx0 && v2->x < mapx0
-	     || v1->x > mapx1 && v2->x > mapx1
-	     || v1->y < mapy0 && v2->y < mapy0
-	     || v1->y > mapy1 && v2->y > mapy1)
-	       continue;  // Off-screen
-	    DrawMapLine (v1->x, v1->y, v2->x, v2->y);
-	 }
-      if (colour != LIGHTRED && Sectors[objnum].tag > 0)
-	 {
-	 for (m = 0; m < NumLineDefs; m++)
-	    if (LineDefs[m].tag == Sectors[objnum].tag)
-	       HighlightObject (OBJ_LINEDEFS, m, LIGHTRED);
-	 }
-      SetLineThickness (0);
-      }
-      break;
-   }
+    case OBJ_SECTORS:
+	{
+	    SetLineThickness(1);
+	    const int mapx0 = MAPX(0);
+	    const int mapy0 = MAPY(ScrMaxY);
+	    const int mapx1 = MAPX(ScrMaxX);
+	    const int mapy1 = MAPY(0);
+	    for (n = 0; n < NumLineDefs; n++)
+		if (LineDefs[n].sidedef1 != -1
+		    && SideDefs[LineDefs[n].sidedef1].sector == objnum
+		    || LineDefs[n].sidedef2 != -1
+		    && SideDefs[LineDefs[n].sidedef2].sector == objnum)
+		{
+		    const struct Vertex *v1 = Vertices + LineDefs[n].start;
+		    const struct Vertex *v2 = Vertices + LineDefs[n].end;
+		    if (v1->x < mapx0 && v2->x < mapx0
+			|| v1->x > mapx1 && v2->x > mapx1
+			|| v1->y < mapy0 && v2->y < mapy0
+			|| v1->y > mapy1 && v2->y > mapy1)
+			continue;	// Off-screen
+		    DrawMapLine(v1->x, v1->y, v2->x, v2->y);
+		}
+	    if (colour != LIGHTRED && Sectors[objnum].tag > 0)
+	    {
+		for (m = 0; m < NumLineDefs; m++)
+		    if (LineDefs[m].tag == Sectors[objnum].tag)
+			HighlightObject(OBJ_LINEDEFS, m, LIGHTRED);
+	    }
+	    SetLineThickness(0);
+	}
+	break;
+    }
 /* restore normal write mode */
-SetDrawingMode (0);
+    SetDrawingMode(0);
 }
 
 
@@ -181,13 +181,13 @@
 /*
    delete an object
 */
-void DeleteObject (const Objid& obj) /* SWAP! */
+void DeleteObject(const Objid & obj)	/* SWAP! */
 {
-SelPtr list;
+    SelPtr list;
 
-list = 0;
-SelectObject (&list, obj.num);
-DeleteObjects (obj.type, &list);
+    list = 0;
+    SelectObject(&list, obj.num);
+    DeleteObjects(obj.type, &list);
 }
 
 
@@ -195,222 +195,227 @@
 /*
    delete a group of objects (*recursive*)
 */
-void DeleteObjects (int objtype, SelPtr *list) /* SWAP! */
+void DeleteObjects(int objtype, SelPtr * list)	/* SWAP! */
 {
-int    n, objnum;
-SelPtr cur;
+    int n, objnum;
+    SelPtr cur;
 
-MadeChanges = 1;
-switch (objtype)
-   {
-   case OBJ_THINGS:
-      if (*list)
-	 {
-	 things_angles++;
-	 things_types++;
-	 }
-      while (*list)
-	 {
-	 objnum = (*list)->objnum;
-	 if (objnum < 0 || objnum >= NumThings)  // Paranoia
-	 {
-	    nf_bug ("attempt to delete non-existent thing #%d", objnum);
-	    goto next_thing;
-	 }
-	 // Delete the thing
-	 NumThings--;
-	 if (NumThings > 0)
+    MadeChanges = 1;
+    switch (objtype)
+    {
+    case OBJ_THINGS:
+	if (*list)
+	{
+	    things_angles++;
+	    things_types++;
+	}
+	while (*list)
+	{
+	    objnum = (*list)->objnum;
+	    if (objnum < 0 || objnum >= NumThings)	// Paranoia
 	    {
-	    for (n = objnum; n < NumThings; n++)
-	       Things[n] = Things[n + 1];
-	    Things = (TPtr) ResizeMemory (Things,
-	       NumThings * sizeof (struct Thing));
+		nf_bug("attempt to delete non-existent thing #%d", objnum);
+		goto next_thing;
 	    }
-	 else
+	    // Delete the thing
+	    NumThings--;
+	    if (NumThings > 0)
 	    {
-	    FreeMemory (Things);
-	    Things = 0;
+		for (n = objnum; n < NumThings; n++)
+		    Things[n] = Things[n + 1];
+		Things = (TPtr) ResizeMemory(Things,
+					     NumThings *
+					     sizeof(struct Thing));
 	    }
-	 for (cur = (*list)->next; cur; cur = cur->next)
-	    if (cur->objnum > objnum)
-	       cur->objnum--;
-	 next_thing:
-	 UnSelectObject (list, objnum);
-	 }
-      break;
+	    else
+	    {
+		FreeMemory(Things);
+		Things = 0;
+	    }
+	    for (cur = (*list)->next; cur; cur = cur->next)
+		if (cur->objnum > objnum)
+		    cur->objnum--;
+	  next_thing:
+	    UnSelectObject(list, objnum);
+	}
+	break;
 
-   case OBJ_VERTICES:
-      if (*list)
-         MadeMapChanges = 1;
-      while (*list)
-	 {
-	 objnum = (*list)->objnum;
-	 if (objnum < 0 || objnum >= NumVertices)  // Paranoia
-	 {
-	    nf_bug ("attempt to delete non-existent vertex #%d", objnum);
-	    goto next_vertex;
-	 }
-	 // Delete the linedefs bound to this vertex and change the references
-	 for (n = 0; n < NumLineDefs; n++)
+    case OBJ_VERTICES:
+	if (*list)
+	    MadeMapChanges = 1;
+	while (*list)
+	{
+	    objnum = (*list)->objnum;
+	    if (objnum < 0 || objnum >= NumVertices)	// Paranoia
+	    {
+		nf_bug("attempt to delete non-existent vertex #%d", objnum);
+		goto next_vertex;
+	    }
+	    // Delete the linedefs bound to this vertex and change the references
+	    for (n = 0; n < NumLineDefs; n++)
 	    {
-	    if (LineDefs[n].start == objnum || LineDefs[n].end == objnum)
-	       DeleteObject (Objid (OBJ_LINEDEFS, n--));
+		if (LineDefs[n].start == objnum || LineDefs[n].end == objnum)
+		    DeleteObject(Objid(OBJ_LINEDEFS, n--));
+		else
+		{
+		    if (LineDefs[n].start >= objnum)
+			LineDefs[n].start--;
+		    if (LineDefs[n].end >= objnum)
+			LineDefs[n].end--;
+		}
+	    }
+	    // Delete the vertex
+	    NumVertices--;
+	    if (NumVertices > 0)
+	    {
+		for (n = objnum; n < NumVertices; n++)
+		    Vertices[n] = Vertices[n + 1];
+		Vertices = (VPtr) ResizeMemory(Vertices,
+					       NumVertices *
+					       sizeof(struct Vertex));
+	    }
 	    else
-	       {
-	       if (LineDefs[n].start >= objnum)
-		  LineDefs[n].start--;
-	       if (LineDefs[n].end >= objnum)
-		  LineDefs[n].end--;
-	       }
+	    {
+		FreeMemory(Vertices);
+		Vertices = 0;
 	    }
-	 // Delete the vertex
-	 NumVertices--;
-	 if (NumVertices > 0)
-	    {
-	    for (n = objnum; n < NumVertices; n++)
-	       Vertices[n] = Vertices[n + 1];
-	    Vertices = (VPtr) ResizeMemory (Vertices,
-	      NumVertices * sizeof (struct Vertex));
-	    }
-	 else
-	    {
-	    FreeMemory (Vertices);
-	    Vertices = 0;
-	    }
-	 for (cur = (*list)->next; cur; cur = cur->next)
-	    if (cur->objnum > objnum)
-	       cur->objnum--;
-	 next_vertex:
-	 UnSelectObject (list, objnum);
-	 }
-      break;
+	    for (cur = (*list)->next; cur; cur = cur->next)
+		if (cur->objnum > objnum)
+		    cur->objnum--;
+	  next_vertex:
+	    UnSelectObject(list, objnum);
+	}
+	break;
 
-   case OBJ_LINEDEFS:
-      /* In DEU, deleting a linedef was not considered to be a
-	 map change. Deleting a _sidedef_ was. In Yadex,
-	 sidedefs are not automatically deleted when the linedef
-	 is because some sidedefs are shared by more than one
-	 linedef. So we need to set MadeMapChanges here. */
-      if (*list)
-         MadeMapChanges = 1;
-      /* AYM 19980203 I've removed the deletion of sidedefs
-         because if several linedefs use the same sidedef, this
-         would lead to trouble. Instead, I let the xref checking
-         take care of that. */
-      while (*list)
-	 {
-	 objnum = (*list)->objnum;
-	 if (objnum < 0 || objnum >= NumLineDefs)  // Paranoia
-	 {
-	    nf_bug ("attempt to delete non-existent linedef #%d", objnum);
-	    goto next_linedef;
-	 }
-	 // delete the linedef
-	 NumLineDefs--;
-	 if (NumLineDefs > 0)
+    case OBJ_LINEDEFS:
+	/* In DEU, deleting a linedef was not considered to be a
+	   map change. Deleting a _sidedef_ was. In Yadex,
+	   sidedefs are not automatically deleted when the linedef
+	   is because some sidedefs are shared by more than one
+	   linedef. So we need to set MadeMapChanges here. */
+	if (*list)
+	    MadeMapChanges = 1;
+	/* AYM 19980203 I've removed the deletion of sidedefs
+	   because if several linedefs use the same sidedef, this
+	   would lead to trouble. Instead, I let the xref checking
+	   take care of that. */
+	while (*list)
+	{
+	    objnum = (*list)->objnum;
+	    if (objnum < 0 || objnum >= NumLineDefs)	// Paranoia
+	    {
+		nf_bug("attempt to delete non-existent linedef #%d", objnum);
+		goto next_linedef;
+	    }
+	    // delete the linedef
+	    NumLineDefs--;
+	    if (NumLineDefs > 0)
 	    {
-	    for (n = objnum; n < NumLineDefs; n++)
-	       LineDefs[n] = LineDefs[n + 1];
-	    LineDefs = (LDPtr) ResizeMemory (LineDefs,
-	      NumLineDefs * sizeof (struct LineDef));
+		for (n = objnum; n < NumLineDefs; n++)
+		    LineDefs[n] = LineDefs[n + 1];
+		LineDefs = (LDPtr) ResizeMemory(LineDefs,
+						NumLineDefs *
+						sizeof(struct LineDef));
 	    }
-	 else
+	    else
 	    {
-	    FreeMemory (LineDefs);
-	    LineDefs = 0;
+		FreeMemory(LineDefs);
+		LineDefs = 0;
 	    }
-	 for (cur = (*list)->next; cur; cur = cur->next)
-	    if (cur->objnum > objnum)
-	       cur->objnum--;
-	 next_linedef:
-	 UnSelectObject (list, objnum);
-	 }
-      break;
+	    for (cur = (*list)->next; cur; cur = cur->next)
+		if (cur->objnum > objnum)
+		    cur->objnum--;
+	  next_linedef:
+	    UnSelectObject(list, objnum);
+	}
+	break;
 
-   case OBJ_SIDEDEFS:
-      if (*list)
-         MadeMapChanges = 1;
-      while (*list)
-	 {
-	 objnum = (*list)->objnum;
-	 if (objnum < 0 || objnum >= NumSideDefs)  // Paranoia
-	 {
-	    nf_bug ("attempt to delete non-existent sidedef #%d", objnum);
-	    goto next_sidedef;
-	 }
-	 /* change the linedefs references */
-	 for (n = 0; n < NumLineDefs; n++)
+    case OBJ_SIDEDEFS:
+	if (*list)
+	    MadeMapChanges = 1;
+	while (*list)
+	{
+	    objnum = (*list)->objnum;
+	    if (objnum < 0 || objnum >= NumSideDefs)	// Paranoia
+	    {
+		nf_bug("attempt to delete non-existent sidedef #%d", objnum);
+		goto next_sidedef;
+	    }
+	    /* change the linedefs references */
+	    for (n = 0; n < NumLineDefs; n++)
 	    {
-	    if (LineDefs[n].sidedef1 == objnum)
-	       LineDefs[n].sidedef1 = -1;
-	    else if (LineDefs[n].sidedef1 >= objnum)
-	       LineDefs[n].sidedef1--;
-	    if (LineDefs[n].sidedef2 == objnum)
-	       LineDefs[n].sidedef2 = -1;
-	    else if (LineDefs[n].sidedef2 >= objnum)
-	       LineDefs[n].sidedef2--;
+		if (LineDefs[n].sidedef1 == objnum)
+		    LineDefs[n].sidedef1 = -1;
+		else if (LineDefs[n].sidedef1 >= objnum)
+		    LineDefs[n].sidedef1--;
+		if (LineDefs[n].sidedef2 == objnum)
+		    LineDefs[n].sidedef2 = -1;
+		else if (LineDefs[n].sidedef2 >= objnum)
+		    LineDefs[n].sidedef2--;
 	    }
-	 /* delete the sidedef */
-	 NumSideDefs--;
-	 if (NumSideDefs > 0)
+	    /* delete the sidedef */
+	    NumSideDefs--;
+	    if (NumSideDefs > 0)
 	    {
-	    for (n = objnum; n < NumSideDefs; n++)
-	       SideDefs[n] = SideDefs[n + 1];
-	    SideDefs = (SDPtr) ResizeMemory (SideDefs,
-	       NumSideDefs * sizeof (struct SideDef));
-	    }
-	 else
-	    {
-	    FreeMemory (SideDefs);
-	    SideDefs = 0;
+		for (n = objnum; n < NumSideDefs; n++)
+		    SideDefs[n] = SideDefs[n + 1];
+		SideDefs = (SDPtr) ResizeMemory(SideDefs,
+						NumSideDefs *
+						sizeof(struct SideDef));
 	    }
-	 for (cur = (*list)->next; cur; cur = cur->next)
-	    if (cur->objnum > objnum)
-	       cur->objnum--;
-	 next_sidedef:
-	 UnSelectObject (list, objnum);
-	 }
-      break;
-   case OBJ_SECTORS:
-      while (*list)
+	    else
+	    {
+		FreeMemory(SideDefs);
+		SideDefs = 0;
+	    }
+	    for (cur = (*list)->next; cur; cur = cur->next)
+		if (cur->objnum > objnum)
+		    cur->objnum--;
+	  next_sidedef:
+	    UnSelectObject(list, objnum);
+	}
+	break;
+    case OBJ_SECTORS:
+	while (*list)
 	{
-	objnum = (*list)->objnum;
-	 if (objnum < 0 || objnum >= NumSectors)  // Paranoia
-	 {
-	    nf_bug ("attempt to delete non-existent sector #%d", objnum);
-	    goto next_sector;
-	 }
-	// Delete the sidedefs bound to this sector and change the references
-	// AYM 19980203: Hmm, hope this is OK with multiply used sidedefs...
-	for (n = 0; n < NumSideDefs; n++)
-	   if (SideDefs[n].sector == objnum)
-	      DeleteObject (Objid (OBJ_SIDEDEFS, n--));
-	   else if (SideDefs[n].sector >= objnum)
-	      SideDefs[n].sector--;
-	/* delete the sector */
-	NumSectors--;
-	if (NumSectors > 0)
-	   {
-	   for (n = objnum; n < NumSectors; n++)
-	      Sectors[n] = Sectors[n + 1];
-	   Sectors = (SPtr) ResizeMemory (Sectors,
-	      NumSectors * sizeof (struct Sector));
-	   }
-	else
-	   {
-	   FreeMemory (Sectors);
-	   Sectors = 0;
-	   }
-	for (cur = (*list)->next; cur; cur = cur->next)
-	   if (cur->objnum > objnum)
-	      cur->objnum--;
-	next_sector:
-	UnSelectObject (list, objnum);
+	    objnum = (*list)->objnum;
+	    if (objnum < 0 || objnum >= NumSectors)	// Paranoia
+	    {
+		nf_bug("attempt to delete non-existent sector #%d", objnum);
+		goto next_sector;
+	    }
+	    // Delete the sidedefs bound to this sector and change the references
+	    // AYM 19980203: Hmm, hope this is OK with multiply used sidedefs...
+	    for (n = 0; n < NumSideDefs; n++)
+		if (SideDefs[n].sector == objnum)
+		    DeleteObject(Objid(OBJ_SIDEDEFS, n--));
+		else if (SideDefs[n].sector >= objnum)
+		    SideDefs[n].sector--;
+	    /* delete the sector */
+	    NumSectors--;
+	    if (NumSectors > 0)
+	    {
+		for (n = objnum; n < NumSectors; n++)
+		    Sectors[n] = Sectors[n + 1];
+		Sectors = (SPtr) ResizeMemory(Sectors,
+					      NumSectors *
+					      sizeof(struct Sector));
+	    }
+	    else
+	    {
+		FreeMemory(Sectors);
+		Sectors = 0;
+	    }
+	    for (cur = (*list)->next; cur; cur = cur->next)
+		if (cur->objnum > objnum)
+		    cur->objnum--;
+	  next_sector:
+	    UnSelectObject(list, objnum);
 	}
-      break;
-   default:
-      nf_bug ("DeleteObjects: bad objtype %d", (int) objtype);
-   }
+	break;
+    default:
+	nf_bug("DeleteObjects: bad objtype %d", (int) objtype);
+    }
 }
 
 
@@ -428,146 +433,158 @@
  *	The object is inserted at the exact coordinates given.
  *	No snapping to grid is done.
  */
-void InsertObject (obj_type_t objtype, obj_no_t copyfrom, int xpos, int ypos)
+void InsertObject(obj_type_t objtype, obj_no_t copyfrom, int xpos, int ypos)
 								/* SWAP! */
 {
-int last;
+    int last;
 
-MadeChanges = 1;
-switch (objtype)
-   {
-   case OBJ_THINGS:
-      last = NumThings++;
-      if (last > 0)
-	 Things = (TPtr) ResizeMemory (Things,
-	   (unsigned long) NumThings * sizeof (struct Thing));
-      else
-	 Things = (TPtr) GetMemory (sizeof (struct Thing));
-      Things[last].xpos = xpos;
-      Things[last].ypos = ypos;
-      things_angles++;
-      things_types++;
-      if (is_obj (copyfrom))
-	 {
-	 Things[last].type  = Things[copyfrom].type;
-	 Things[last].angle = Things[copyfrom].angle;
-	 Things[last].when  = Things[copyfrom].when;
-	 }
-      else
-	 {
-	 Things[last].type = default_thing;
-	 Things[last].angle = 0;
-	 Things[last].when  = 0x07;
-	 }
-      break;
+    MadeChanges = 1;
+    switch (objtype)
+    {
+    case OBJ_THINGS:
+	last = NumThings++;
+	if (last > 0)
+	    Things = (TPtr) ResizeMemory(Things,
+					 (unsigned long) NumThings *
+					 sizeof(struct Thing));
+	else
+	    Things = (TPtr) GetMemory(sizeof(struct Thing));
+	Things[last].xpos = xpos;
+	Things[last].ypos = ypos;
+	things_angles++;
+	things_types++;
+	if (is_obj(copyfrom))
+	{
+	    Things[last].type = Things[copyfrom].type;
+	    Things[last].angle = Things[copyfrom].angle;
+	    Things[last].when = Things[copyfrom].when;
+	}
+	else
+	{
+	    Things[last].type = default_thing;
+	    Things[last].angle = 0;
+	    Things[last].when = 0x07;
+	}
+	break;
 
-   case OBJ_VERTICES:
-      last = NumVertices++;
-      if (last > 0)
-	 Vertices = (VPtr) ResizeMemory (Vertices,
-	   (unsigned long) NumVertices * sizeof (struct Vertex));
-      else
-	 Vertices = (VPtr) GetMemory (sizeof (struct Vertex));
-      Vertices[last].x = xpos;
-      Vertices[last].y = ypos;
-      if (Vertices[last].x < MapMinX)
-	 MapMinX = Vertices[last].x;
-      if (Vertices[last].x > MapMaxX)
-	 MapMaxX = Vertices[last].x;
-      if (Vertices[last].y < MapMinY)
-	 MapMinY = Vertices[last].y;
-      if (Vertices[last].y > MapMaxY)
-	 MapMaxY = Vertices[last].y;
-      MadeMapChanges = 1;
-      break;
+    case OBJ_VERTICES:
+	last = NumVertices++;
+	if (last > 0)
+	    Vertices = (VPtr) ResizeMemory(Vertices,
+					   (unsigned long) NumVertices *
+					   sizeof(struct Vertex));
+	else
+	    Vertices = (VPtr) GetMemory(sizeof(struct Vertex));
+	Vertices[last].x = xpos;
+	Vertices[last].y = ypos;
+	if (Vertices[last].x < MapMinX)
+	    MapMinX = Vertices[last].x;
+	if (Vertices[last].x > MapMaxX)
+	    MapMaxX = Vertices[last].x;
+	if (Vertices[last].y < MapMinY)
+	    MapMinY = Vertices[last].y;
+	if (Vertices[last].y > MapMaxY)
+	    MapMaxY = Vertices[last].y;
+	MadeMapChanges = 1;
+	break;
 
-   case OBJ_LINEDEFS:
-      last = NumLineDefs++;
-      if (last > 0)
-	 LineDefs = (LDPtr) ResizeMemory (LineDefs,
-	   (unsigned long) NumLineDefs * sizeof (struct LineDef));
-      else
-	 LineDefs = (LDPtr) GetMemory (sizeof (struct LineDef));
-      if (is_obj (copyfrom))
-	 {
-	 LineDefs[last].start = LineDefs[copyfrom].start;
-	 LineDefs[last].end   = LineDefs[copyfrom].end;
-	 LineDefs[last].flags = LineDefs[copyfrom].flags;
-	 LineDefs[last].type  = LineDefs[copyfrom].type;
-	 LineDefs[last].tag   = LineDefs[copyfrom].tag;
-	 }
-      else
-	 {
-	 LineDefs[last].start = 0;
-	 LineDefs[last].end   = NumVertices - 1;
-	 LineDefs[last].flags = 1;
-	 LineDefs[last].type  = 0;
-	 LineDefs[last].tag   = 0;
-	 }
-      LineDefs[last].sidedef1 = OBJ_NO_NONE;
-      LineDefs[last].sidedef2 = OBJ_NO_NONE;
-      break;
+    case OBJ_LINEDEFS:
+	last = NumLineDefs++;
+	if (last > 0)
+	    LineDefs = (LDPtr) ResizeMemory(LineDefs,
+					    (unsigned long) NumLineDefs *
+					    sizeof(struct LineDef));
+	else
+	    LineDefs = (LDPtr) GetMemory(sizeof(struct LineDef));
+	if (is_obj(copyfrom))
+	{
+	    LineDefs[last].start = LineDefs[copyfrom].start;
+	    LineDefs[last].end = LineDefs[copyfrom].end;
+	    LineDefs[last].flags = LineDefs[copyfrom].flags;
+	    LineDefs[last].type = LineDefs[copyfrom].type;
+	    LineDefs[last].tag = LineDefs[copyfrom].tag;
+	}
+	else
+	{
+	    LineDefs[last].start = 0;
+	    LineDefs[last].end = NumVertices - 1;
+	    LineDefs[last].flags = 1;
+	    LineDefs[last].type = 0;
+	    LineDefs[last].tag = 0;
+	}
+	LineDefs[last].sidedef1 = OBJ_NO_NONE;
+	LineDefs[last].sidedef2 = OBJ_NO_NONE;
+	break;
 
-   case OBJ_SIDEDEFS:
-      last = NumSideDefs++;
-      if (last > 0)
-	 SideDefs = (SDPtr) ResizeMemory (SideDefs,
-	   (unsigned long) NumSideDefs * sizeof (struct SideDef));
-      else
-	 SideDefs = (SDPtr) GetMemory (sizeof (struct SideDef));
-      if (is_obj (copyfrom))
-	 {
-	 SideDefs[last].xoff = SideDefs[copyfrom].xoff;
-	 SideDefs[last].yoff = SideDefs[copyfrom].yoff;
-	 strncpy (SideDefs[last].tex1, SideDefs[copyfrom].tex1, WAD_TEX_NAME);
-	 strncpy (SideDefs[last].tex2, SideDefs[copyfrom].tex2, WAD_TEX_NAME);
-	 strncpy (SideDefs[last].tex3, SideDefs[copyfrom].tex3, WAD_TEX_NAME);
-	 SideDefs[last].sector = SideDefs[copyfrom].sector;
-	 }
-      else
-	 {
-	 SideDefs[last].xoff = 0;
-	 SideDefs[last].yoff = 0;
-	 strcpy (SideDefs[last].tex1, "-");
-	 strcpy (SideDefs[last].tex2, "-");
-	 strcpy (SideDefs[last].tex3, default_middle_texture);
-	 SideDefs[last].sector = NumSectors - 1;
-	 }
-      MadeMapChanges = 1;
-      break;
+    case OBJ_SIDEDEFS:
+	last = NumSideDefs++;
+	if (last > 0)
+	    SideDefs = (SDPtr) ResizeMemory(SideDefs,
+					    (unsigned long) NumSideDefs *
+					    sizeof(struct SideDef));
+	else
+	    SideDefs = (SDPtr) GetMemory(sizeof(struct SideDef));
+	if (is_obj(copyfrom))
+	{
+	    SideDefs[last].xoff = SideDefs[copyfrom].xoff;
+	    SideDefs[last].yoff = SideDefs[copyfrom].yoff;
+	    strncpy(SideDefs[last].tex1, SideDefs[copyfrom].tex1,
+		    WAD_TEX_NAME);
+	    strncpy(SideDefs[last].tex2, SideDefs[copyfrom].tex2,
+		    WAD_TEX_NAME);
+	    strncpy(SideDefs[last].tex3, SideDefs[copyfrom].tex3,
+		    WAD_TEX_NAME);
+	    SideDefs[last].sector = SideDefs[copyfrom].sector;
+	}
+	else
+	{
+	    SideDefs[last].xoff = 0;
+	    SideDefs[last].yoff = 0;
+	    strcpy(SideDefs[last].tex1, "-");
+	    strcpy(SideDefs[last].tex2, "-");
+	    strcpy(SideDefs[last].tex3, default_middle_texture);
+	    SideDefs[last].sector = NumSectors - 1;
+	}
+	MadeMapChanges = 1;
+	break;
 
-   case OBJ_SECTORS:
-      last = NumSectors++;
-      if (last > 0)
-	 Sectors = (SPtr) ResizeMemory (Sectors,
-			  (unsigned long) NumSectors * sizeof (struct Sector));
-      else
-	 Sectors = (SPtr) GetMemory (sizeof (struct Sector));
-      if (is_obj (copyfrom))
-	 {
-	 Sectors[last].floorh  = Sectors[copyfrom].floorh;
-	 Sectors[last].ceilh   = Sectors[copyfrom].ceilh;
-	 strncpy (Sectors[last].floort, Sectors[copyfrom].floort, WAD_FLAT_NAME);
-	 strncpy (Sectors[last].ceilt, Sectors[copyfrom].ceilt, WAD_FLAT_NAME);
-	 Sectors[last].light   = Sectors[copyfrom].light;
-	 Sectors[last].special = Sectors[copyfrom].special;
-	 Sectors[last].tag     = Sectors[copyfrom].tag;
-	 }
-      else
-	 {
-	 Sectors[last].floorh  = default_floor_height;
-	 Sectors[last].ceilh   = default_ceiling_height;
-	 strncpy (Sectors[last].floort, default_floor_texture, WAD_FLAT_NAME);
-	 strncpy (Sectors[last].ceilt, default_ceiling_texture, WAD_FLAT_NAME);
-	 Sectors[last].light   = default_light_level;
-	 Sectors[last].special = 0;
-	 Sectors[last].tag     = 0;
-	 }
-      break;
+    case OBJ_SECTORS:
+	last = NumSectors++;
+	if (last > 0)
+	    Sectors = (SPtr) ResizeMemory(Sectors,
+					  (unsigned long) NumSectors *
+					  sizeof(struct Sector));
+	else
+	    Sectors = (SPtr) GetMemory(sizeof(struct Sector));
+	if (is_obj(copyfrom))
+	{
+	    Sectors[last].floorh = Sectors[copyfrom].floorh;
+	    Sectors[last].ceilh = Sectors[copyfrom].ceilh;
+	    strncpy(Sectors[last].floort, Sectors[copyfrom].floort,
+		    WAD_FLAT_NAME);
+	    strncpy(Sectors[last].ceilt, Sectors[copyfrom].ceilt,
+		    WAD_FLAT_NAME);
+	    Sectors[last].light = Sectors[copyfrom].light;
+	    Sectors[last].special = Sectors[copyfrom].special;
+	    Sectors[last].tag = Sectors[copyfrom].tag;
+	}
+	else
+	{
+	    Sectors[last].floorh = default_floor_height;
+	    Sectors[last].ceilh = default_ceiling_height;
+	    strncpy(Sectors[last].floort, default_floor_texture,
+		    WAD_FLAT_NAME);
+	    strncpy(Sectors[last].ceilt, default_ceiling_texture,
+		    WAD_FLAT_NAME);
+	    Sectors[last].light = default_light_level;
+	    Sectors[last].special = 0;
+	    Sectors[last].tag = 0;
+	}
+	break;
 
-   default:
-      nf_bug ("InsertObject: bad objtype %d", (int) objtype);
-   }
+    default:
+	nf_bug("InsertObject: bad objtype %d", (int) objtype);
+    }
 }
 
 
@@ -575,44 +592,52 @@
 /*
    check if a (part of a) LineDef is inside a given block
 */
-bool IsLineDefInside (int ldnum, int x0, int y0, int x1, int y1) /* SWAP - needs Vertices & LineDefs */
+bool IsLineDefInside(int ldnum, int x0, int y0, int x1, int y1)	/* SWAP - needs Vertices & LineDefs */
 {
-int lx0 = Vertices[LineDefs[ldnum].start].x;
-int ly0 = Vertices[LineDefs[ldnum].start].y;
-int lx1 = Vertices[LineDefs[ldnum].end].x;
-int ly1 = Vertices[LineDefs[ldnum].end].y;
-int i;
+    int lx0 = Vertices[LineDefs[ldnum].start].x;
+    int ly0 = Vertices[LineDefs[ldnum].start].y;
+    int lx1 = Vertices[LineDefs[ldnum].end].x;
+    int ly1 = Vertices[LineDefs[ldnum].end].y;
+    int i;
 
 /* do you like mathematics? */
-if (lx0 >= x0 && lx0 <= x1 && ly0 >= y0 && ly0 <= y1)
-   return 1; /* the linedef start is entirely inside the square */
-if (lx1 >= x0 && lx1 <= x1 && ly1 >= y0 && ly1 <= y1)
-   return 1; /* the linedef end is entirely inside the square */
-if ((ly0 > y0) != (ly1 > y0))
-   {
-   i = lx0 + (int) ((long) (y0 - ly0) * (long) (lx1 - lx0) / (long) (ly1 - ly0));
-   if (i >= x0 && i <= x1)
-      return true; /* the linedef crosses the y0 side (left) */
-   }
-if ((ly0 > y1) != (ly1 > y1))
-   {
-   i = lx0 + (int) ((long) (y1 - ly0) * (long) (lx1 - lx0) / (long) (ly1 - ly0));
-   if (i >= x0 && i <= x1)
-      return true; /* the linedef crosses the y1 side (right) */
-   }
-if ((lx0 > x0) != (lx1 > x0))
-   {
-   i = ly0 + (int) ((long) (x0 - lx0) * (long) (ly1 - ly0) / (long) (lx1 - lx0));
-   if (i >= y0 && i <= y1)
-      return true; /* the linedef crosses the x0 side (down) */
-   }
-if ((lx0 > x1) != (lx1 > x1))
-   {
-   i = ly0 + (int) ((long) (x1 - lx0) * (long) (ly1 - ly0) / (long) (lx1 - lx0));
-   if (i >= y0 && i <= y1)
-      return true; /* the linedef crosses the x1 side (up) */
-   }
-return false;
+    if (lx0 >= x0 && lx0 <= x1 && ly0 >= y0 && ly0 <= y1)
+	return 1;		/* the linedef start is entirely inside the square */
+    if (lx1 >= x0 && lx1 <= x1 && ly1 >= y0 && ly1 <= y1)
+	return 1;		/* the linedef end is entirely inside the square */
+    if ((ly0 > y0) != (ly1 > y0))
+    {
+	i = lx0 +
+	    (int) ((long) (y0 - ly0) * (long) (lx1 - lx0) /
+		   (long) (ly1 - ly0));
+	if (i >= x0 && i <= x1)
+	    return true;	/* the linedef crosses the y0 side (left) */
+    }
+    if ((ly0 > y1) != (ly1 > y1))
+    {
+	i = lx0 +
+	    (int) ((long) (y1 - ly0) * (long) (lx1 - lx0) /
+		   (long) (ly1 - ly0));
+	if (i >= x0 && i <= x1)
+	    return true;	/* the linedef crosses the y1 side (right) */
+    }
+    if ((lx0 > x0) != (lx1 > x0))
+    {
+	i = ly0 +
+	    (int) ((long) (x0 - lx0) * (long) (ly1 - ly0) /
+		   (long) (lx1 - lx0));
+	if (i >= y0 && i <= y1)
+	    return true;	/* the linedef crosses the x0 side (down) */
+    }
+    if ((lx0 > x1) != (lx1 > x1))
+    {
+	i = ly0 +
+	    (int) ((long) (x1 - lx0) * (long) (ly1 - ly0) /
+		   (long) (lx1 - lx0));
+	if (i >= y0 && i <= y1)
+	    return true;	/* the linedef crosses the x1 side (up) */
+    }
+    return false;
 }
 
 
@@ -621,163 +646,179 @@
    get the sector number of the sidedef opposite to this sidedef
    (returns -1 if it cannot be found)
 */
-int GetOppositeSector (int ld1, bool firstside) /* SWAP! */
+int GetOppositeSector(int ld1, bool firstside)	/* SWAP! */
 {
-int x0, y0, dx0, dy0;
-int x1, y1, dx1, dy1;
-int x2, y2, dx2, dy2;
-int ld2, dist;
-int bestld, bestdist, bestmdist;
+    int x0, y0, dx0, dy0;
+    int x1, y1, dx1, dy1;
+    int x2, y2, dx2, dy2;
+    int ld2, dist;
+    int bestld, bestdist, bestmdist;
 
 /* get the coords for this LineDef */
-x0  = Vertices[LineDefs[ld1].start].x;
-y0  = Vertices[LineDefs[ld1].start].y;
-dx0 = Vertices[LineDefs[ld1].end].x - x0;
-dy0 = Vertices[LineDefs[ld1].end].y - y0;
+    x0 = Vertices[LineDefs[ld1].start].x;
+    y0 = Vertices[LineDefs[ld1].start].y;
+    dx0 = Vertices[LineDefs[ld1].end].x - x0;
+    dy0 = Vertices[LineDefs[ld1].end].y - y0;
 
 /* find the normal vector for this LineDef */
-x1  = (dx0 + x0 + x0) / 2;
-y1  = (dy0 + y0 + y0) / 2;
-if (firstside)
-   {
-   dx1 = dy0;
-   dy1 = -dx0;
-   }
-else
-   {
-   dx1 = -dy0;
-   dy1 = dx0;
-   }
+    x1 = (dx0 + x0 + x0) / 2;
+    y1 = (dy0 + y0 + y0) / 2;
+    if (firstside)
+    {
+	dx1 = dy0;
+	dy1 = -dx0;
+    }
+    else
+    {
+	dx1 = -dy0;
+	dy1 = dx0;
+    }
 
-bestld = -1;
+    bestld = -1;
 /* use a parallel to an axis instead of the normal vector (faster method) */
-if (abs (dy1) > abs (dx1))
-   {
-   if (dy1 > 0)
-      {
-      /* get the nearest LineDef in that direction (increasing Y's: North) */
-      bestdist = 32767;
-      bestmdist = 32767;
-      for (ld2 = 0; ld2 < NumLineDefs; ld2++)
-	 if (ld2 != ld1 && ((Vertices[LineDefs[ld2].start].x > x1)
-			 != (Vertices[LineDefs[ld2].end].x > x1)))
-	    {
-	    x2  = Vertices[LineDefs[ld2].start].x;
-	    y2  = Vertices[LineDefs[ld2].start].y;
-	    dx2 = Vertices[LineDefs[ld2].end].x - x2;
-	    dy2 = Vertices[LineDefs[ld2].end].y - y2;
-	    dist = y2 + (int) ((long) (x1 - x2) * (long) dy2 / (long) dx2);
-	    if (dist > y1 && (dist < bestdist
-	     || (dist == bestdist && (y2 + dy2 / 2) < bestmdist)))
-	       {
-	       bestld = ld2;
-	       bestdist = dist;
-	       bestmdist = y2 + dy2 / 2;
-	       }
-	    }
-      }
-   else
-      {
-      /* get the nearest LineDef in that direction (decreasing Y's: South) */
-      bestdist = -32767;
-      bestmdist = -32767;
-      for (ld2 = 0; ld2 < NumLineDefs; ld2++)
-	 if (ld2 != ld1 && ((Vertices[LineDefs[ld2].start].x > x1)
-			 != (Vertices[LineDefs[ld2].end].x > x1)))
-	    {
-	    x2  = Vertices[LineDefs[ld2].start].x;
-	    y2  = Vertices[LineDefs[ld2].start].y;
-	    dx2 = Vertices[LineDefs[ld2].end].x - x2;
-	    dy2 = Vertices[LineDefs[ld2].end].y - y2;
-	    dist = y2 + (int) ((long) (x1 - x2) * (long) dy2 / (long) dx2);
-	    if (dist < y1 && (dist > bestdist
-	     || (dist == bestdist && (y2 + dy2 / 2) > bestmdist)))
-	       {
-	       bestld = ld2;
-	       bestdist = dist;
-	       bestmdist = y2 + dy2 / 2;
-	       }
-	    }
-      }
-   }
-else
-   {
-   if (dx1 > 0)
-      {
-      /* get the nearest LineDef in that direction (increasing X's: East) */
-      bestdist = 32767;
-      bestmdist = 32767;
-      for (ld2 = 0; ld2 < NumLineDefs; ld2++)
-	 if (ld2 != ld1 && ((Vertices[LineDefs[ld2].start].y > y1)
-			 != (Vertices[LineDefs[ld2].end].y > y1)))
-	    {
-	    x2  = Vertices[LineDefs[ld2].start].x;
-	    y2  = Vertices[LineDefs[ld2].start].y;
-	    dx2 = Vertices[LineDefs[ld2].end].x - x2;
-	    dy2 = Vertices[LineDefs[ld2].end].y - y2;
-	    dist = x2 + (int) ((long) (y1 - y2) * (long) dx2 / (long) dy2);
-	    if (dist > x1 && (dist < bestdist
-	     || (dist == bestdist && (x2 + dx2 / 2) < bestmdist)))
-	       {
-	       bestld = ld2;
-	       bestdist = dist;
-	       bestmdist = x2 + dx2 / 2;
-	       }
-	    }
-      }
-   else
-      {
-      /* get the nearest LineDef in that direction (decreasing X's: West) */
-      bestdist = -32767;
-      bestmdist = -32767;
-      for (ld2 = 0; ld2 < NumLineDefs; ld2++)
-	 if (ld2 != ld1 && ((Vertices[LineDefs[ld2].start].y > y1)
-			 != (Vertices[LineDefs[ld2].end].y > y1)))
-	    {
-	    x2  = Vertices[LineDefs[ld2].start].x;
-	    y2  = Vertices[LineDefs[ld2].start].y;
-	    dx2 = Vertices[LineDefs[ld2].end].x - x2;
-	    dy2 = Vertices[LineDefs[ld2].end].y - y2;
-	    dist = x2 + (int) ((long) (y1 - y2) * (long) dx2 / (long) dy2);
-	    if (dist < x1 && (dist > bestdist
-	     || (dist == bestdist && (x2 + dx2 / 2) > bestmdist)))
-	       {
-	       bestld = ld2;
-	       bestdist = dist;
-	       bestmdist = x2 + dx2 / 2;
-	       }
-	    }
-      }
-   }
+    if (abs(dy1) > abs(dx1))
+    {
+	if (dy1 > 0)
+	{
+	    /* get the nearest LineDef in that direction (increasing Y's: North) */
+	    bestdist = 32767;
+	    bestmdist = 32767;
+	    for (ld2 = 0; ld2 < NumLineDefs; ld2++)
+		if (ld2 != ld1 && ((Vertices[LineDefs[ld2].start].x > x1)
+				   != (Vertices[LineDefs[ld2].end].x > x1)))
+		{
+		    x2 = Vertices[LineDefs[ld2].start].x;
+		    y2 = Vertices[LineDefs[ld2].start].y;
+		    dx2 = Vertices[LineDefs[ld2].end].x - x2;
+		    dy2 = Vertices[LineDefs[ld2].end].y - y2;
+		    dist =
+			y2 +
+			(int) ((long) (x1 - x2) * (long) dy2 / (long) dx2);
+		    if (dist > y1
+			&& (dist < bestdist
+			    || (dist == bestdist
+				&& (y2 + dy2 / 2) < bestmdist)))
+		    {
+			bestld = ld2;
+			bestdist = dist;
+			bestmdist = y2 + dy2 / 2;
+		    }
+		}
+	}
+	else
+	{
+	    /* get the nearest LineDef in that direction (decreasing Y's: South) */
+	    bestdist = -32767;
+	    bestmdist = -32767;
+	    for (ld2 = 0; ld2 < NumLineDefs; ld2++)
+		if (ld2 != ld1 && ((Vertices[LineDefs[ld2].start].x > x1)
+				   != (Vertices[LineDefs[ld2].end].x > x1)))
+		{
+		    x2 = Vertices[LineDefs[ld2].start].x;
+		    y2 = Vertices[LineDefs[ld2].start].y;
+		    dx2 = Vertices[LineDefs[ld2].end].x - x2;
+		    dy2 = Vertices[LineDefs[ld2].end].y - y2;
+		    dist =
+			y2 +
+			(int) ((long) (x1 - x2) * (long) dy2 / (long) dx2);
+		    if (dist < y1
+			&& (dist > bestdist
+			    || (dist == bestdist
+				&& (y2 + dy2 / 2) > bestmdist)))
+		    {
+			bestld = ld2;
+			bestdist = dist;
+			bestmdist = y2 + dy2 / 2;
+		    }
+		}
+	}
+    }
+    else
+    {
+	if (dx1 > 0)
+	{
+	    /* get the nearest LineDef in that direction (increasing X's: East) */
+	    bestdist = 32767;
+	    bestmdist = 32767;
+	    for (ld2 = 0; ld2 < NumLineDefs; ld2++)
+		if (ld2 != ld1 && ((Vertices[LineDefs[ld2].start].y > y1)
+				   != (Vertices[LineDefs[ld2].end].y > y1)))
+		{
+		    x2 = Vertices[LineDefs[ld2].start].x;
+		    y2 = Vertices[LineDefs[ld2].start].y;
+		    dx2 = Vertices[LineDefs[ld2].end].x - x2;
+		    dy2 = Vertices[LineDefs[ld2].end].y - y2;
+		    dist =
+			x2 +
+			(int) ((long) (y1 - y2) * (long) dx2 / (long) dy2);
+		    if (dist > x1
+			&& (dist < bestdist
+			    || (dist == bestdist
+				&& (x2 + dx2 / 2) < bestmdist)))
+		    {
+			bestld = ld2;
+			bestdist = dist;
+			bestmdist = x2 + dx2 / 2;
+		    }
+		}
+	}
+	else
+	{
+	    /* get the nearest LineDef in that direction (decreasing X's: West) */
+	    bestdist = -32767;
+	    bestmdist = -32767;
+	    for (ld2 = 0; ld2 < NumLineDefs; ld2++)
+		if (ld2 != ld1 && ((Vertices[LineDefs[ld2].start].y > y1)
+				   != (Vertices[LineDefs[ld2].end].y > y1)))
+		{
+		    x2 = Vertices[LineDefs[ld2].start].x;
+		    y2 = Vertices[LineDefs[ld2].start].y;
+		    dx2 = Vertices[LineDefs[ld2].end].x - x2;
+		    dy2 = Vertices[LineDefs[ld2].end].y - y2;
+		    dist =
+			x2 +
+			(int) ((long) (y1 - y2) * (long) dx2 / (long) dy2);
+		    if (dist < x1
+			&& (dist > bestdist
+			    || (dist == bestdist
+				&& (x2 + dx2 / 2) > bestmdist)))
+		    {
+			bestld = ld2;
+			bestdist = dist;
+			bestmdist = x2 + dx2 / 2;
+		    }
+		}
+	}
+    }
 
 /* no intersection: the LineDef was pointing outwards! */
-if (bestld < 0)
-   return -1;
+    if (bestld < 0)
+	return -1;
 
 /* now look if this LineDef has a SideDef bound to one sector */
-if (abs (dy1) > abs (dx1))
-   {
-   if ((Vertices[LineDefs[bestld].start].x
-	< Vertices[LineDefs[bestld].end].x) == (dy1 > 0))
-      x0 = LineDefs[bestld].sidedef1;
-   else
-      x0 = LineDefs[bestld].sidedef2;
-   }
-else
-   {
-   if ((Vertices[LineDefs[bestld].start].y
-      < Vertices[LineDefs[bestld].end].y) != (dx1 > 0))
-      x0 = LineDefs[bestld].sidedef1;
-   else
-      x0 = LineDefs[bestld].sidedef2;
-   }
+    if (abs(dy1) > abs(dx1))
+    {
+	if ((Vertices[LineDefs[bestld].start].x
+	     < Vertices[LineDefs[bestld].end].x) == (dy1 > 0))
+	    x0 = LineDefs[bestld].sidedef1;
+	else
+	    x0 = LineDefs[bestld].sidedef2;
+    }
+    else
+    {
+	if ((Vertices[LineDefs[bestld].start].y
+	     < Vertices[LineDefs[bestld].end].y) != (dx1 > 0))
+	    x0 = LineDefs[bestld].sidedef1;
+	else
+	    x0 = LineDefs[bestld].sidedef2;
+    }
 
 /* there is no SideDef on this side of the LineDef! */
-if (x0 < 0)
-   return -1;
+    if (x0 < 0)
+	return -1;
 
 /* OK, we got it -- return the Sector number */
-return SideDefs[x0].sector;
+    return SideDefs[x0].sector;
 }
 
 
@@ -785,171 +826,168 @@
 /*
    copy a group of objects to a new position
 */
-void CopyObjects (int objtype, SelPtr obj) /* SWAP! */
+void CopyObjects(int objtype, SelPtr obj)	/* SWAP! */
 {
-int        n, m;
-SelPtr     cur;
-SelPtr     list1, list2;
-SelPtr     ref1, ref2;
+    int n, m;
+    SelPtr cur;
+    SelPtr list1, list2;
+    SelPtr ref1, ref2;
 
-if (! obj)
-   return;
+    if (!obj)
+	return;
 
 /* copy the object(s) */
-switch (objtype)
-   {
-   case OBJ_THINGS:
-      for (cur = obj; cur; cur = cur->next)
-	 {
-	 InsertObject (OBJ_THINGS, cur->objnum, Things[cur->objnum].xpos,
-						Things[cur->objnum].ypos);
-	 cur->objnum = NumThings - 1;
-	 }
-      MadeChanges = 1;
-      break;
+    switch (objtype)
+    {
+    case OBJ_THINGS:
+	for (cur = obj; cur; cur = cur->next)
+	{
+	    InsertObject(OBJ_THINGS, cur->objnum, Things[cur->objnum].xpos,
+			 Things[cur->objnum].ypos);
+	    cur->objnum = NumThings - 1;
+	}
+	MadeChanges = 1;
+	break;
 
-   case OBJ_VERTICES:
-      for (cur = obj; cur; cur = cur->next)
-	 {
-	 InsertObject (OBJ_VERTICES, cur->objnum, Vertices[cur->objnum].x,
-						  Vertices[cur->objnum].y);
-	 cur->objnum = NumVertices - 1;
-	 }
-      MadeChanges = 1;
-      MadeMapChanges = 1;
-      break;
+    case OBJ_VERTICES:
+	for (cur = obj; cur; cur = cur->next)
+	{
+	    InsertObject(OBJ_VERTICES, cur->objnum, Vertices[cur->objnum].x,
+			 Vertices[cur->objnum].y);
+	    cur->objnum = NumVertices - 1;
+	}
+	MadeChanges = 1;
+	MadeMapChanges = 1;
+	break;
 
-   case OBJ_LINEDEFS:
-      list1 = 0;
-      list2 = 0;
+    case OBJ_LINEDEFS:
+	list1 = 0;
+	list2 = 0;
 
-      // Create the linedefs and maybe the sidedefs
-      for (cur = obj; cur; cur = cur->next)
-	 {
-         int old = cur->objnum;	// No. of original linedef
-         int New;		// No. of duplicate linedef
+	// Create the linedefs and maybe the sidedefs
+	for (cur = obj; cur; cur = cur->next)
+	{
+	    int old = cur->objnum;	// No. of original linedef
+	    int New;		// No. of duplicate linedef
 
-	 InsertObject (OBJ_LINEDEFS, old, 0, 0);
-         New = NumLineDefs - 1;
+	    InsertObject(OBJ_LINEDEFS, old, 0, 0);
+	    New = NumLineDefs - 1;
 
-         if (copy_linedef_reuse_sidedefs)
+	    if (copy_linedef_reuse_sidedefs)
 	    {
-	    /* AYM 1997-07-25: not very orthodox (the New linedef and 
-	       the old one use the same sidedefs). but, in the case where
-	       you're copying into the same sector, it's much better than
-	       having to create the New sidedefs manually. plus it saves
-	       space in the .wad and also it makes editing easier (editing
-	       one sidedef impacts all linedefs that use it). */
-	    LineDefs[New].sidedef1 = LineDefs[old].sidedef1; 
-	    LineDefs[New].sidedef2 = LineDefs[old].sidedef2; 
+		/* AYM 1997-07-25: not very orthodox (the New linedef and 
+		   the old one use the same sidedefs). but, in the case where
+		   you're copying into the same sector, it's much better than
+		   having to create the New sidedefs manually. plus it saves
+		   space in the .wad and also it makes editing easier (editing
+		   one sidedef impacts all linedefs that use it). */
+		LineDefs[New].sidedef1 = LineDefs[old].sidedef1;
+		LineDefs[New].sidedef2 = LineDefs[old].sidedef2;
 	    }
-         else
-            {
-            /* AYM 1998-11-08: duplicate sidedefs too.
-               DEU 5.21 just left the sidedef references to -1. */
-            if (is_sidedef (LineDefs[old].sidedef1))
-	       {
-	       InsertObject (OBJ_SIDEDEFS, LineDefs[old].sidedef1, 0, 0);
-	       LineDefs[New].sidedef1 = NumSideDefs - 1;
-	       }
-            if (is_sidedef (LineDefs[old].sidedef2))
-	       {
-	       InsertObject (OBJ_SIDEDEFS, LineDefs[old].sidedef2, 0, 0);
-	       LineDefs[New].sidedef2 = NumSideDefs - 1; 
-	       }
-            }
-	 cur->objnum = New;
-	 if (!IsSelected (list1, LineDefs[New].start))
+	    else
 	    {
-	    SelectObject (&list1, LineDefs[New].start);
-	    SelectObject (&list2, LineDefs[New].start);
+		/* AYM 1998-11-08: duplicate sidedefs too.
+		   DEU 5.21 just left the sidedef references to -1. */
+		if (is_sidedef(LineDefs[old].sidedef1))
+		{
+		    InsertObject(OBJ_SIDEDEFS, LineDefs[old].sidedef1, 0, 0);
+		    LineDefs[New].sidedef1 = NumSideDefs - 1;
+		}
+		if (is_sidedef(LineDefs[old].sidedef2))
+		{
+		    InsertObject(OBJ_SIDEDEFS, LineDefs[old].sidedef2, 0, 0);
+		    LineDefs[New].sidedef2 = NumSideDefs - 1;
+		}
 	    }
-	 if (!IsSelected (list1, LineDefs[New].end))
+	    cur->objnum = New;
+	    if (!IsSelected(list1, LineDefs[New].start))
 	    {
-	    SelectObject (&list1, LineDefs[New].end);
-	    SelectObject (&list2, LineDefs[New].end);
+		SelectObject(&list1, LineDefs[New].start);
+		SelectObject(&list2, LineDefs[New].start);
 	    }
-	 }
+	    if (!IsSelected(list1, LineDefs[New].end))
+	    {
+		SelectObject(&list1, LineDefs[New].end);
+		SelectObject(&list2, LineDefs[New].end);
+	    }
+	}
 
-      // Create the vertices
-      CopyObjects (OBJ_VERTICES, list2);
+	// Create the vertices
+	CopyObjects(OBJ_VERTICES, list2);
 
-      // Update the references to the vertices
-      for (ref1 = list1, ref2 = list2;
-	   ref1 && ref2;
-	   ref1 = ref1->next, ref2 = ref2->next)
-	 {
-	 for (cur = obj; cur; cur = cur->next)
+	// Update the references to the vertices
+	for (ref1 = list1, ref2 = list2;
+	     ref1 && ref2; ref1 = ref1->next, ref2 = ref2->next)
+	{
+	    for (cur = obj; cur; cur = cur->next)
 	    {
-	    if (ref1->objnum == LineDefs[cur->objnum].start)
-	      LineDefs[cur->objnum].start = ref2->objnum;
-	    if (ref1->objnum == LineDefs[cur->objnum].end)
-	      LineDefs[cur->objnum].end = ref2->objnum;
+		if (ref1->objnum == LineDefs[cur->objnum].start)
+		    LineDefs[cur->objnum].start = ref2->objnum;
+		if (ref1->objnum == LineDefs[cur->objnum].end)
+		    LineDefs[cur->objnum].end = ref2->objnum;
 	    }
-	 }
-      ForgetSelection (&list1);
-      ForgetSelection (&list2);
-      break;
+	}
+	ForgetSelection(&list1);
+	ForgetSelection(&list2);
+	break;
 
-   case OBJ_SECTORS:
-      list1 = 0;
-      list2 = 0;
-      // Create the linedefs (and vertices)
-      for (cur = obj; cur; cur = cur->next)
-	 {
-	 for (n = 0; n < NumLineDefs; n++)
-	    if  ((((m = LineDefs[n].sidedef1) >= 0
-		       && SideDefs[m].sector == cur->objnum)
-		|| ((m = LineDefs[n].sidedef2) >= 0
-		       && SideDefs[m].sector == cur->objnum))
-		       && ! IsSelected (list1, n))
-	       {
-	       SelectObject (&list1, n);
-	       SelectObject (&list2, n);
-	       }
-	 }
-      CopyObjects (OBJ_LINEDEFS, list2);
-      /* create the sidedefs */
-      for (ref1 = list1, ref2 = list2;
-	   ref1 && ref2;
-	   ref1 = ref1->next, ref2 = ref2->next)
-	 {
-	 if ((n = LineDefs[ref1->objnum].sidedef1) >= 0)
+    case OBJ_SECTORS:
+	list1 = 0;
+	list2 = 0;
+	// Create the linedefs (and vertices)
+	for (cur = obj; cur; cur = cur->next)
+	{
+	    for (n = 0; n < NumLineDefs; n++)
+		if ((((m = LineDefs[n].sidedef1) >= 0
+		      && SideDefs[m].sector == cur->objnum)
+		     || ((m = LineDefs[n].sidedef2) >= 0
+			 && SideDefs[m].sector == cur->objnum))
+		    && !IsSelected(list1, n))
+		{
+		    SelectObject(&list1, n);
+		    SelectObject(&list2, n);
+		}
+	}
+	CopyObjects(OBJ_LINEDEFS, list2);
+	/* create the sidedefs */
+	for (ref1 = list1, ref2 = list2;
+	     ref1 && ref2; ref1 = ref1->next, ref2 = ref2->next)
+	{
+	    if ((n = LineDefs[ref1->objnum].sidedef1) >= 0)
 	    {
-	    InsertObject (OBJ_SIDEDEFS, n, 0, 0);
-	    n = NumSideDefs - 1;
-	    LineDefs[ref2->objnum].sidedef1 = n;
+		InsertObject(OBJ_SIDEDEFS, n, 0, 0);
+		n = NumSideDefs - 1;
+		LineDefs[ref2->objnum].sidedef1 = n;
 	    }
-	 if ((m = LineDefs[ref1->objnum].sidedef2) >= 0)
+	    if ((m = LineDefs[ref1->objnum].sidedef2) >= 0)
 	    {
-	    InsertObject (OBJ_SIDEDEFS, m, 0, 0);
-	    m = NumSideDefs - 1;
-	    LineDefs[ref2->objnum].sidedef2 = m;
+		InsertObject(OBJ_SIDEDEFS, m, 0, 0);
+		m = NumSideDefs - 1;
+		LineDefs[ref2->objnum].sidedef2 = m;
 	    }
-	 ref1->objnum = n;
-	 ref2->objnum = m;
-	 }
-      /* create the Sectors */
-      for (cur = obj; cur; cur = cur->next)
-	 {
-	 InsertObject (OBJ_SECTORS, cur->objnum, 0, 0);
-	 for (ref1 = list1, ref2 = list2;
-	      ref1 && ref2;
-	      ref1 = ref1->next, ref2 = ref2->next)
+	    ref1->objnum = n;
+	    ref2->objnum = m;
+	}
+	/* create the Sectors */
+	for (cur = obj; cur; cur = cur->next)
+	{
+	    InsertObject(OBJ_SECTORS, cur->objnum, 0, 0);
+	    for (ref1 = list1, ref2 = list2;
+		 ref1 && ref2; ref1 = ref1->next, ref2 = ref2->next)
 	    {
-	    if (ref1->objnum >= 0
-               && SideDefs[ref1->objnum].sector == cur->objnum)
-	       SideDefs[ref1->objnum].sector = NumSectors - 1;
-	    if (ref2->objnum >= 0
-               && SideDefs[ref2->objnum].sector == cur->objnum)
-	       SideDefs[ref2->objnum].sector = NumSectors - 1;
+		if (ref1->objnum >= 0
+		    && SideDefs[ref1->objnum].sector == cur->objnum)
+		    SideDefs[ref1->objnum].sector = NumSectors - 1;
+		if (ref2->objnum >= 0
+		    && SideDefs[ref2->objnum].sector == cur->objnum)
+		    SideDefs[ref2->objnum].sector = NumSectors - 1;
 	    }
-	 cur->objnum = NumSectors - 1;
-	 }
-      ForgetSelection (&list1);
-      ForgetSelection (&list2);
-      break;
-   }
+	    cur->objnum = NumSectors - 1;
+	}
+	ForgetSelection(&list1);
+	ForgetSelection(&list2);
+	break;
+    }
 }
 
 
@@ -967,77 +1005,72 @@
  *
  *	Returns <>0 iff an object was moved.
  */
-bool MoveObjectsToCoords (
-   int objtype,
-   SelPtr obj,
-   int newx,
-   int newy,
-   int grid) /* SWAP! */
+bool MoveObjectsToCoords(int objtype, SelPtr obj, int newx, int newy, int grid)	/* SWAP! */
 {
-int        dx, dy;
-SelPtr     cur, vertices;
-static int refx, refy; /* previous position */
+    int dx, dy;
+    SelPtr cur, vertices;
+    static int refx, refy;	/* previous position */
 
-if (grid > 0)
-   {
-   newx = (newx + grid / 2) & ~(grid - 1);
-   newy = (newy + grid / 2) & ~(grid - 1);
-   }
+    if (grid > 0)
+    {
+	newx = (newx + grid / 2) & ~(grid - 1);
+	newy = (newy + grid / 2) & ~(grid - 1);
+    }
 
 // Only update the reference point ?
-if (! obj)
-   {
-   refx = newx;
-   refy = newy;
-   return true;
-   }
+    if (!obj)
+    {
+	refx = newx;
+	refy = newy;
+	return true;
+    }
 
 /* compute the displacement */
-dx = newx - refx;
-dy = newy - refy;
+    dx = newx - refx;
+    dy = newy - refy;
 /* nothing to do? */
-if (dx == 0 && dy == 0)
-   return false;
+    if (dx == 0 && dy == 0)
+	return false;
 
 /* move the object(s) */
-switch (objtype)
-   {
-   case OBJ_THINGS:
-      for (cur = obj; cur; cur = cur->next)
-	 {
-	 Things[cur->objnum].xpos += dx;
-	 Things[cur->objnum].ypos += dy;
-	 }
-      refx = newx;
-      refy = newy;
-      MadeChanges = 1;
-      break;
+    switch (objtype)
+    {
+    case OBJ_THINGS:
+	for (cur = obj; cur; cur = cur->next)
+	{
+	    Things[cur->objnum].xpos += dx;
+	    Things[cur->objnum].ypos += dy;
+	}
+	refx = newx;
+	refy = newy;
+	MadeChanges = 1;
+	break;
 
-   case OBJ_VERTICES:
-      for (cur = obj; cur; cur = cur->next)
-	 {
-	 Vertices[cur->objnum].x += dx;
-	 Vertices[cur->objnum].y += dy;
-	 }
-      refx = newx;
-      refy = newy;
-      MadeChanges = 1;
-      MadeMapChanges = 1;
-      break;
+    case OBJ_VERTICES:
+	for (cur = obj; cur; cur = cur->next)
+	{
+	    Vertices[cur->objnum].x += dx;
+	    Vertices[cur->objnum].y += dy;
+	}
+	refx = newx;
+	refy = newy;
+	MadeChanges = 1;
+	MadeMapChanges = 1;
+	break;
 
-   case OBJ_LINEDEFS:
-      vertices = list_vertices_of_linedefs (obj);
-      MoveObjectsToCoords (OBJ_VERTICES, vertices, newx, newy, grid);
-      ForgetSelection (&vertices);
-      break;
+    case OBJ_LINEDEFS:
+	vertices = list_vertices_of_linedefs(obj);
+	MoveObjectsToCoords(OBJ_VERTICES, vertices, newx, newy, grid);
+	ForgetSelection(&vertices);
+	break;
 
-   case OBJ_SECTORS:
-      vertices = list_vertices_of_sectors (obj);
-      MoveObjectsToCoords (OBJ_VERTICES, vertices, newx, newy, grid);
-      ForgetSelection (&vertices);
-      break;
-   }
-return true;
+    case OBJ_SECTORS:
+	vertices = list_vertices_of_sectors(obj);
+	MoveObjectsToCoords(OBJ_VERTICES, vertices, newx, newy, grid);
+	ForgetSelection(&vertices);
+	break;
+    }
+    return true;
 }
 
 
@@ -1045,118 +1078,119 @@
 /*
    get the coordinates (approx.) of an object
 */
-void GetObjectCoords (int objtype, int objnum, int *xpos, int *ypos) /* SWAP! */
+void GetObjectCoords(int objtype, int objnum, int *xpos, int *ypos)	/* SWAP! */
 {
-int  n, v1, v2, sd1, sd2;
-long accx, accy, num;
+    int n, v1, v2, sd1, sd2;
+    long accx, accy, num;
 
-switch (objtype)
-   {
-   case OBJ_THINGS:
-      if (! is_thing (objnum))		// Can't happen
-	 {
-	 nf_bug ("GetObjectCoords: bad thing# %d", objnum);
-	 *xpos = 0;
-	 *ypos = 0;
-	 return;
-	 }
-      *xpos = Things[objnum].xpos;
-      *ypos = Things[objnum].ypos;
-      break;
+    switch (objtype)
+    {
+    case OBJ_THINGS:
+	if (!is_thing(objnum))	// Can't happen
+	{
+	    nf_bug("GetObjectCoords: bad thing# %d", objnum);
+	    *xpos = 0;
+	    *ypos = 0;
+	    return;
+	}
+	*xpos = Things[objnum].xpos;
+	*ypos = Things[objnum].ypos;
+	break;
+
+    case OBJ_VERTICES:
+	if (!is_vertex(objnum))	// Can't happen
+	{
+	    nf_bug("GetObjectCoords: bad vertex# %d", objnum);
+	    *xpos = 0;
+	    *ypos = 0;
+	    return;
+	}
+	*xpos = Vertices[objnum].x;
+	*ypos = Vertices[objnum].y;
+	break;
 
-   case OBJ_VERTICES:
-      if (! is_vertex (objnum))		// Can't happen
-	 {
-	 nf_bug ("GetObjectCoords: bad vertex# %d", objnum);
-	 *xpos = 0;
-	 *ypos = 0;
-	 return;
-	 }
-      *xpos = Vertices[objnum].x;
-      *ypos = Vertices[objnum].y;
-      break;
+    case OBJ_LINEDEFS:
+	if (!is_linedef(objnum))	// Can't happen
+	{
+	    nf_bug("GetObjectCoords: bad linedef# %d", objnum);
+	    *xpos = 0;
+	    *ypos = 0;
+	    return;
+	}
+	v1 = LineDefs[objnum].start;
+	v2 = LineDefs[objnum].end;
+	*xpos = (Vertices[v1].x + Vertices[v2].x) / 2;
+	*ypos = (Vertices[v1].y + Vertices[v2].y) / 2;
+	break;
 
-   case OBJ_LINEDEFS:
-      if (! is_linedef (objnum))	// Can't happen
-	 {
-	 nf_bug ("GetObjectCoords: bad linedef# %d", objnum);
-	 *xpos = 0;
-	 *ypos = 0;
-	 return;
-	 }
-      v1 = LineDefs[objnum].start;
-      v2 = LineDefs[objnum].end;
-      *xpos = (Vertices[v1].x + Vertices[v2].x) / 2;
-      *ypos = (Vertices[v1].y + Vertices[v2].y) / 2;
-      break;
+    case OBJ_SIDEDEFS:
+	if (!is_sidedef(objnum))	// Can't happen
+	{
+	    nf_bug("GetObjectCoords: bad sidedef# %d", objnum);
+	    *xpos = 0;
+	    *ypos = 0;
+	    return;
+	}
+	for (n = 0; n < NumLineDefs; n++)
+	    if (LineDefs[n].sidedef1 == objnum
+		|| LineDefs[n].sidedef2 == objnum)
+	    {
+		v1 = LineDefs[n].start;
+		v2 = LineDefs[n].end;
+		*xpos = (Vertices[v1].x + Vertices[v2].x) / 2;
+		*ypos = (Vertices[v1].y + Vertices[v2].y) / 2;
+		return;
+	    }
+	*xpos = (MapMinX + MapMaxX) / 2;
+	*ypos = (MapMinY + MapMaxY) / 2;
+	// FIXME is the fall through intentional ? -- AYM 2000-11-08
 
-   case OBJ_SIDEDEFS:
-      if (! is_sidedef (objnum))	// Can't happen
-	 {
-	 nf_bug ("GetObjectCoords: bad sidedef# %d", objnum);
-	 *xpos = 0;
-	 *ypos = 0;
-	 return;
-	 }
-      for (n = 0; n < NumLineDefs; n++)
-	 if (LineDefs[n].sidedef1 == objnum || LineDefs[n].sidedef2 == objnum)
-	    {
+    case OBJ_SECTORS:
+	if (!is_sector(objnum))	// Can't happen
+	{
+	    nf_bug("GetObjectCoords: bad sector# %d", objnum);
+	    *xpos = 0;
+	    *ypos = 0;
+	    return;
+	}
+	accx = 0L;
+	accy = 0L;
+	num = 0L;
+	for (n = 0; n < NumLineDefs; n++)
+	{
+	    sd1 = LineDefs[n].sidedef1;
+	    sd2 = LineDefs[n].sidedef2;
 	    v1 = LineDefs[n].start;
 	    v2 = LineDefs[n].end;
-	    *xpos = (Vertices[v1].x + Vertices[v2].x) / 2;
-	    *ypos = (Vertices[v1].y + Vertices[v2].y) / 2;
-	    return;
+	    if ((sd1 >= 0 && SideDefs[sd1].sector == objnum)
+		|| (sd2 >= 0 && SideDefs[sd2].sector == objnum))
+	    {
+		/* if the Sector is closed, all Vertices will be counted twice */
+		accx += (long) Vertices[v1].x;
+		accy += (long) Vertices[v1].y;
+		num++;
+		accx += (long) Vertices[v2].x;
+		accy += (long) Vertices[v2].y;
+		num++;
 	    }
-      *xpos = (MapMinX + MapMaxX) / 2;
-      *ypos = (MapMinY + MapMaxY) / 2;
-      // FIXME is the fall through intentional ? -- AYM 2000-11-08
+	}
+	if (num > 0)
+	{
+	    *xpos = (int) ((accx + num / 2L) / num);
+	    *ypos = (int) ((accy + num / 2L) / num);
+	}
+	else
+	{
+	    *xpos = (MapMinX + MapMaxX) / 2;
+	    *ypos = (MapMinY + MapMaxY) / 2;
+	}
+	break;
 
-   case OBJ_SECTORS:
-      if (! is_sector (objnum))		// Can't happen
-	 {
-	 nf_bug ("GetObjectCoords: bad sector# %d", objnum);
-	 *xpos = 0;
-	 *ypos = 0;
-	 return;
-	 }
-      accx = 0L;
-      accy = 0L;
-      num = 0L;
-      for (n = 0; n < NumLineDefs; n++)
-	 {
-	 sd1 = LineDefs[n].sidedef1;
-	 sd2 = LineDefs[n].sidedef2;
-	 v1 = LineDefs[n].start;
-	 v2 = LineDefs[n].end;
-	 if ((sd1 >= 0 && SideDefs[sd1].sector == objnum)
-	       || (sd2 >= 0 && SideDefs[sd2].sector == objnum))
-	    {
-	    /* if the Sector is closed, all Vertices will be counted twice */
-	    accx += (long) Vertices[v1].x;
-	    accy += (long) Vertices[v1].y;
-	    num++;
-	    accx += (long) Vertices[v2].x;
-	    accy += (long) Vertices[v2].y;
-	    num++;
-	    }
-	 }
-      if (num > 0)
-	 {
-	 *xpos = (int) ((accx + num / 2L) / num);
-	 *ypos = (int) ((accy + num / 2L) / num);
-	 }
-      else
-	 {
-	 *xpos = (MapMinX + MapMaxX) / 2;
-	 *ypos = (MapMinY + MapMaxY) / 2;
-	 }
-      break;
-
-   default:
-      nf_bug ("GetObjectCoords: bad objtype %d", objtype);  // Can't happen
-      *xpos = 0;
-      *ypos = 0;
-   }
+    default:
+	nf_bug("GetObjectCoords: bad objtype %d", objtype);	// Can't happen
+	*xpos = 0;
+	*ypos = 0;
+    }
 }
 
 
@@ -1164,32 +1198,30 @@
 /*
    find a free tag number
 */
-int FindFreeTag () /* SWAP! */
+int FindFreeTag()		/* SWAP! */
 {
-int  tag, n;
-bool ok;
+    int tag, n;
+    bool ok;
 
-tag = 1;
-ok = false;
-while (! ok)
-   {
-   ok = true;
-   for (n = 0; n < NumLineDefs; n++)
-      if (LineDefs[n].tag == tag)
-	 {
-	 ok = false;
-	 break;
-	 }
-   if (ok)
-      for (n = 0; n < NumSectors; n++)
-	 if (Sectors[n].tag == tag)
+    tag = 1;
+    ok = false;
+    while (!ok)
+    {
+	ok = true;
+	for (n = 0; n < NumLineDefs; n++)
+	    if (LineDefs[n].tag == tag)
 	    {
-	    ok = false;
-	    break;
+		ok = false;
+		break;
 	    }
-   tag++;
-   }
-return tag - 1;
+	if (ok)
+	    for (n = 0; n < NumSectors; n++)
+		if (Sectors[n].tag == tag)
+		{
+		    ok = false;
+		    break;
+		}
+	tag++;
+    }
+    return tag - 1;
 }
-
-
--- a/src/objects.h	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/objects.h	Sat Sep 24 14:16:04 2011 +0300
@@ -4,27 +4,27 @@
  */
 
 
-#ifndef YH_OBJECTS  /* DO NOT INSERT ANYTHING BEFORE THIS LINE */
+#ifndef YH_OBJECTS		/* DO NOT INSERT ANYTHING BEFORE THIS LINE */
 #define YH_OBJECTS
 
 
 #include "objid.h"
 
 
-void	HighlightSelection (int, SelPtr);
-obj_no_t GetMaxObjectNum (int);
-void	GetCurObject (Objid& o, int objtype, int x, int y);
-void	SelectObjectsInBox (SelPtr *list, int, int, int, int, int);
-void	HighlightObject (int, int, int);
-void	DeleteObject (const Objid&);
-void	DeleteObjects (int, SelPtr *);
-void	InsertObject (obj_type_t, obj_no_t, int, int);
-bool	IsLineDefInside (int, int, int, int, int);
-int	GetOppositeSector (int, bool);
-void	CopyObjects (int, SelPtr);
-bool	MoveObjectsToCoords (int, SelPtr, int, int, int);
-void	GetObjectCoords (int, int, int *, int *);
-int	FindFreeTag (void);
+void HighlightSelection(int, SelPtr);
+obj_no_t GetMaxObjectNum(int);
+void GetCurObject(Objid & o, int objtype, int x, int y);
+void SelectObjectsInBox(SelPtr * list, int, int, int, int, int);
+void HighlightObject(int, int, int);
+void DeleteObject(const Objid &);
+void DeleteObjects(int, SelPtr *);
+void InsertObject(obj_type_t, obj_no_t, int, int);
+bool IsLineDefInside(int, int, int, int, int);
+int GetOppositeSector(int, bool);
+void CopyObjects(int, SelPtr);
+bool MoveObjectsToCoords(int, SelPtr, int, int, int);
+void GetObjectCoords(int, int, int *, int *);
+int FindFreeTag(void);
 
 
-#endif  /* DO NOT ADD ANYTHING AFTER THIS LINE */
+#endif /* DO NOT ADD ANYTHING AFTER THIS LINE */
--- a/src/objid.h	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/objid.h	Sat Sep 24 14:16:04 2011 +0300
@@ -25,7 +25,7 @@
 */
 
 
-#ifndef YH_OBJID  /* DO NOT INSERT ANYTHING BEFORE THIS LINE */
+#ifndef YH_OBJID		/* DO NOT INSERT ANYTHING BEFORE THIS LINE */
 #define YH_OBJID
 
 
@@ -48,7 +48,7 @@
 #define OBJ_ANY		11
 
 // Special object numbers
-typedef i16  obj_no_t;
+typedef i16 obj_no_t;
 typedef char obj_type_t;
 #define OBJ_NO_NONE    -1
 #define OBJ_NO_CANVAS  -2
@@ -61,23 +61,52 @@
 
 class Objid
 {
-  public :
-    Objid () { num = -1; type = OBJ_NONE; }
-    Objid (obj_type_t t, obj_no_t n) { type = t; num = n; }
-    bool operator== (const Objid& other) const
+    public: Objid()
+    {
+	num = -1;
+	type = OBJ_NONE;
+    }
+    Objid(obj_type_t t, obj_no_t n)
     {
-      return other.type == type && other.num == num;
+	type = t;
+	num = n;
+    }
+    bool operator==(const Objid & other) const
+    {
+	return other.type == type && other.num == num;
+    }
+    bool _is_linedef() const
+    {
+	return type == OBJ_LINEDEFS && num >= 0;
+    }
+    bool _is_sector() const
+    {
+	return type == OBJ_SECTORS && num >= 0;
     }
-    bool _is_linedef () const { return type == OBJ_LINEDEFS && num >= 0; }
-    bool _is_sector  () const { return type == OBJ_SECTORS  && num >= 0; }
-    bool _is_thing   () const { return type == OBJ_THINGS   && num >= 0; }
-    bool _is_vertex  () const { return type == OBJ_VERTICES && num >= 0; }
-    bool is_nil     () const { return num <  0 || type == OBJ_NONE; }
-    bool operator() () const { return num >= 0 && type != OBJ_NONE; } 
-    void nil () { num = -1; type = OBJ_NONE; }
+    bool _is_thing() const
+    {
+	return type == OBJ_THINGS && num >= 0;
+    }
+    bool _is_vertex() const
+    {
+	return type == OBJ_VERTICES && num >= 0;
+    }
+    bool is_nil() const
+    {
+	return num < 0 || type == OBJ_NONE;
+    }
+    bool operator() () const
+    {
+	return num >= 0 && type != OBJ_NONE;
+    }
+    void nil()
+    {
+	num = -1;
+	type = OBJ_NONE;
+    }
     obj_type_t type;
-    obj_no_t   num;
+    obj_no_t num;
 };
 
 
-#endif  /* DO NOT ADD ANYTHING AFTER THIS LINE */
+#endif /* DO NOT ADD ANYTHING AFTER THIS LINE */
--- a/src/objinfo.cc	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/objinfo.cc	Sat Sep 24 14:16:04 2011 +0300
@@ -32,9 +32,9 @@
 #include <algorithm>
 #include <X11/Xlib.h>
 #include "disppic.h"
-#include "flats.h"	// DisplayFloorTexture()
-#include "game.h"	// THINGDEF_SPECTRAL
-#include "gamesky.h"	// is_sky()
+#include "flats.h"		// DisplayFloorTexture()
+#include "game.h"		// THINGDEF_SPECTRAL
+#include "gamesky.h"		// is_sky()
 #include "gfx.h"
 #include "img.h"
 #include "imgspect.h"
@@ -48,7 +48,7 @@
 #include "wadres.h"
 
 
-static const int sprite_width  = 90;
+static const int sprite_width = 90;
 static const int sprite_height = 90;
 
 
@@ -57,686 +57,723 @@
  */
 class Extraf
 {
-  public :
-    Extraf (obj_no_t sector, wad_name_t& tex, wad_z_t height)
+    public: Extraf(obj_no_t sector, wad_name_t & tex, wad_z_t height)
     {
-      this->sector = sector;
-      memcpy (this->tex, &tex, sizeof this->tex);
-      this->height = height;
+	this->sector = sector;
+	memcpy(this->tex, &tex, sizeof this->tex);
+	this->height = height;
     }
 
-    bool operator< (const Extraf& other) const
+    bool operator<(const Extraf & other) const
     {
-      if (height < other.height)
-	return true;
-      else if (height == other.height && sector < other.sector)
-	return true;
-      return false;
+	if (height < other.height)
+	    return true;
+	else if (height == other.height && sector < other.sector)
+	    return true;
+	return false;
     }
 
-    wad_z_t height;	// To sort by increasing floor height
-    obj_no_t sector;	// Sector# (for heights, flats and light level)
-    wad_tex_name_t tex;	// Texture (middle tex of first sidedef)
+    wad_z_t height;		// To sort by increasing floor height
+    obj_no_t sector;		// Sector# (for heights, flats and light level)
+    wad_tex_name_t tex;		// Texture (middle tex of first sidedef)
 };
 
 
-static void get_extrafloors (std::vector<Extraf>& list, wad_tag_t tag);
+static void get_extrafloors(std::vector < Extraf > &list, wad_tag_t tag);
 
 
-objinfo_c::objinfo_c ()
+objinfo_c::objinfo_c()
 {
-  for (size_t n = 0; n < MAX_BOXES; n++)
-    box_disp[n] = false;
-  obj_no      = OBJ_NO_NONE;
-  obj_no_disp = OBJ_NO_NONE;
-  prev_sector = OBJ_NO_NONE;
-  out_y1      = 0;
+    for (size_t n = 0; n < MAX_BOXES; n++)
+	box_disp[n] = false;
+    obj_no = OBJ_NO_NONE;
+    obj_no_disp = OBJ_NO_NONE;
+    prev_sector = OBJ_NO_NONE;
+    out_y1 = 0;
 }
 
 
-void objinfo_c::draw ()
+void objinfo_c::draw()
 {
-  int  n;
-  int  sd1 = OBJ_NO_NONE;
-  int  sd2 = OBJ_NO_NONE;
-  int  s1 = OBJ_NO_NONE;
-  int  s2 = OBJ_NO_NONE;
-  int  x0, y0;		// Outer top left corner
-  int  ix0, iy0;		// Inner top left corner
-  int  width;
-  int  height;
+    int n;
+    int sd1 = OBJ_NO_NONE;
+    int sd2 = OBJ_NO_NONE;
+    int s1 = OBJ_NO_NONE;
+    int s2 = OBJ_NO_NONE;
+    int x0, y0;			// Outer top left corner
+    int ix0, iy0;		// Inner top left corner
+    int width;
+    int height;
 
-  // Am I already drawn ?
-  if (! is_obj (obj_no) || obj_no == obj_no_disp && obj_type == obj_type_disp)
-    return;
-
-  // Does the box need to be redrawn ?
-  if (obj_type != obj_type_disp)
-    box_disp[0] = false;
+    // Am I already drawn ?
+    if (!is_obj(obj_no) || obj_no == obj_no_disp && obj_type == obj_type_disp)
+	return;
 
-  // The caller should have called set_y1() before !
-  if (! out_y1)
-    return;
+    // Does the box need to be redrawn ?
+    if (obj_type != obj_type_disp)
+	box_disp[0] = false;
 
-  switch (obj_type)
-  {
-    case OBJ_THINGS:
+    // The caller should have called set_y1() before !
+    if (!out_y1)
+	return;
+
+    switch (obj_type)
     {
-      const int columns = 27;
-      width  = 2 * BOX_BORDER + 3 * WIDE_HSPACING + columns * FONTW
-	     + 2 * HOLLOW_BORDER + sprite_width;
-      height = 2 * BOX_BORDER + 2 * WIDE_VSPACING
-	     + y_max ((int) (6.5 * FONTH), sprite_height);
-      x0 = 0;
-      y0 = out_y1 - height + 1;
-      ix0 = x0 + BOX_BORDER + WIDE_HSPACING;
-      iy0 = y0 + BOX_BORDER + WIDE_VSPACING;
-      int ix1 = x0 + width - 1 - BOX_BORDER - WIDE_HSPACING;
-      int iy1 = y0 + height - 1 - BOX_BORDER - WIDE_VSPACING;
-      if (box_disp[0])
-      {
-	push_colour (WINBG);
-	DrawScreenBox (ix0, iy0, ix0 + columns * FONTW - 1, iy1);
-	pop_colour ();
-      }
-      else
-	DrawScreenBox3D (x0, y0, x0 + width - 1, y0 + height - 1);
-      if (obj_no < 0)
-      {
-	const char *message = "(no thing selected)";
-	set_colour (WINFG_DIM);
-	DrawScreenText (x0 + (width - FONTW * strlen (message)) / 2,
-	   y0 + (height - FONTH) / 2, message);
+    case OBJ_THINGS:
+	{
+	    const int columns = 27;
+	    width = 2 * BOX_BORDER + 3 * WIDE_HSPACING + columns * FONTW
+		+ 2 * HOLLOW_BORDER + sprite_width;
+	    height = 2 * BOX_BORDER + 2 * WIDE_VSPACING
+		+ y_max((int) (6.5 * FONTH), sprite_height);
+	    x0 = 0;
+	    y0 = out_y1 - height + 1;
+	    ix0 = x0 + BOX_BORDER + WIDE_HSPACING;
+	    iy0 = y0 + BOX_BORDER + WIDE_VSPACING;
+	    int ix1 = x0 + width - 1 - BOX_BORDER - WIDE_HSPACING;
+	    int iy1 = y0 + height - 1 - BOX_BORDER - WIDE_VSPACING;
+	    if (box_disp[0])
+	    {
+		push_colour(WINBG);
+		DrawScreenBox(ix0, iy0, ix0 + columns * FONTW - 1, iy1);
+		pop_colour();
+	    }
+	    else
+		DrawScreenBox3D(x0, y0, x0 + width - 1, y0 + height - 1);
+	    if (obj_no < 0)
+	    {
+		const char *message = "(no thing selected)";
+		set_colour(WINFG_DIM);
+		DrawScreenText(x0 + (width - FONTW * strlen(message)) / 2,
+			       y0 + (height - FONTH) / 2, message);
+		break;
+	    }
+	    set_colour(WINTITLE);
+	    DrawScreenText(ix0, iy0, "Thing #%d", obj_no);
+	    const bool invalid_type = !is_thing_type(Things[obj_no].type);
+	    set_colour(WINFG);
+	    DrawScreenText(-1, iy0 + (int) (1.5 * FONTH), 0);
+	    DrawScreenText(-1, -1, "\1Coords:\2 (%d, %d)",
+			   Things[obj_no].xpos, Things[obj_no].ypos);
+	    DrawScreenString(-1, -1, "\1Type:   ");
+	    if (invalid_type)
+		push_colour(CLR_ERROR);
+	    DrawScreenText(-2, -2, "%d", Things[obj_no].type);
+	    if (invalid_type)
+		pop_colour();
+	    DrawScreenString(-1, -1, "\1Desc:   ");
+	    if (invalid_type)
+		push_colour(CLR_ERROR);
+	    DrawScreenText(-2, -2, "%.19s",
+			   get_thing_name(Things[obj_no].type));
+	    if (invalid_type)
+		pop_colour();
+	    DrawScreenText(-1, -1, "\1Angle:\2  %s",
+			   GetAngleName(Things[obj_no].angle));
+	    DrawScreenText(-1, -1, "\1Flags:\2  %s",
+			   GetWhenName(Things[obj_no].when));
+
+	    // Show the corresponding sprite
+	    {
+		int sx1 = ix1 + 1 - HOLLOW_BORDER;
+		int sy1 = iy1 + 1 - HOLLOW_BORDER;
+		int sx0 = sx1 + 1 - sprite_width;
+		int sy0 = sy1 + 1 - sprite_height;
+		draw_box_border(sx0 - HOLLOW_BORDER, sy0 - HOLLOW_BORDER,
+				sprite_width + 2 * HOLLOW_BORDER,
+				sprite_height + 2 * HOLLOW_BORDER,
+				HOLLOW_BORDER, 0);
+		const char *sprite_root =
+		    get_thing_sprite(Things[obj_no].type);
+		char flags = get_thing_flags(Things[obj_no].type);
+		if (sprite_root == NULL)
+		{
+		    push_colour(WINBG);
+		    DrawScreenBox(sx0, sy0, sx1, sy1);
+		    pop_colour();
+		    set_colour(WINFG_DIM);
+		    DrawScreenText(sx0 + (sprite_width - 2 * FONTW) / 2,
+				   sy0 + sprite_height / 2 + 1 - FONTH, "no");
+		    DrawScreenText(sx0 + (sprite_width - 6 * FONTW) / 2,
+				   sy0 + sprite_height / 2 + 1, "sprite");
+		}
+		else
+		{
+		    Lump_loc loc;
+		    Img img(sprite_width, sprite_height, false);
+		    Sticker sticker;
+		    wad_res.sprites.loc_by_root(sprite_root, loc);
+		    if (loc.wad == 0
+			|| LoadPicture(img, sprite_root, loc, INT_MIN,
+				       INT_MIN))
+		    {
+			push_colour(WINBG);
+			DrawScreenBox(sx0, sy0, sx1, sy1);
+			pop_colour();
+			set_colour(CLR_ERROR);
+			DrawScreenString(sx0 +
+					 (sprite_width -
+					  strlen(sprite_root) * FONTW) / 2,
+					 sy0 + sprite_height / 2 + 1 -
+					 3 * FONTH / 2, sprite_root);
+			DrawScreenText(sx0 + (sprite_width - 3 * FONTW) / 2,
+				       sy0 + sprite_height / 2 + 1 -
+				       FONTH / 2, "not");
+			DrawScreenText(sx0 + (sprite_width - 5 * FONTW) / 2,
+				       sy0 + sprite_height / 2 + 1 +
+				       FONTH / 2, "found");
+		    }
+		    else
+		    {
+			if (flags & THINGDEF_SPECTRAL)
+			    spectrify_img(img);
+			sticker.load(img, true);
+			sticker.draw(drw, 't', sx0, sy0);
+		    }
+		}
+	    }
+	}
 	break;
-      }
-      set_colour (WINTITLE);
-      DrawScreenText (ix0, iy0, "Thing #%d", obj_no);
-      const bool invalid_type = ! is_thing_type (Things[obj_no].type);
-      set_colour (WINFG);
-      DrawScreenText (-1, iy0 + (int) (1.5 * FONTH), 0);
-      DrawScreenText (-1, -1, "\1Coords:\2 (%d, %d)",
-	Things[obj_no].xpos, Things[obj_no].ypos);
-      DrawScreenString (-1, -1, "\1Type:   ");
-      if (invalid_type)
-	push_colour (CLR_ERROR);
-      DrawScreenText (-2, -2, "%d", Things[obj_no].type);
-      if (invalid_type)
-	pop_colour ();
-      DrawScreenString (-1, -1, "\1Desc:   ");
-      if (invalid_type)
-	push_colour (CLR_ERROR);
-      DrawScreenText (-2, -2, "%.19s", get_thing_name (Things[obj_no].type));
-      if (invalid_type)
-	pop_colour ();
-      DrawScreenText (-1, -1, "\1Angle:\2  %s",
-	GetAngleName (Things[obj_no].angle));
-      DrawScreenText (-1, -1, "\1Flags:\2  %s",
-	GetWhenName (Things[obj_no].when));
 
-      // Show the corresponding sprite
-      {
-	int sx1 = ix1 + 1 - HOLLOW_BORDER;
-	int sy1 = iy1 + 1 - HOLLOW_BORDER;
-	int sx0 = sx1 + 1 - sprite_width;
-	int sy0 = sy1 + 1 - sprite_height;
-	draw_box_border (sx0 - HOLLOW_BORDER, sy0 - HOLLOW_BORDER, 
-			 sprite_width + 2 * HOLLOW_BORDER,
-			 sprite_height + 2 * HOLLOW_BORDER,
-			 HOLLOW_BORDER, 0);
-	const char *sprite_root = get_thing_sprite (Things[obj_no].type);
-	char        flags       = get_thing_flags  (Things[obj_no].type);
-	if (sprite_root == NULL)
+    case OBJ_LINEDEFS:
+	// Linedef
+	width = 2 * BOX_BORDER + 2 * WIDE_HSPACING + 29 * FONTW;
+	height = 2 * BOX_BORDER + 2 * WIDE_VSPACING + (int) (8.5 * FONTH);
+	x0 = 0;
+	y0 = out_y1 - height + 1;
+	ix0 = x0 + BOX_BORDER + WIDE_HSPACING;
+	iy0 = y0 + BOX_BORDER + WIDE_VSPACING;
+	// Ignore box_disp -- always redraw the whole box
+	DrawScreenBox3D(x0, y0, x0 + width - 1, y0 + height - 1);
+	if (obj_no >= 0)
 	{
-	  push_colour (WINBG);
-	  DrawScreenBox (sx0, sy0, sx1, sy1);
-	  pop_colour ();
-	  set_colour (WINFG_DIM);
-	  DrawScreenText (
-	     sx0 + (sprite_width - 2 * FONTW) / 2,
-	     sy0 + sprite_height / 2 + 1 - FONTH, "no");
-	  DrawScreenText (
-	     sx0 + (sprite_width - 6 * FONTW) / 2,
-	     sy0 + sprite_height / 2 + 1, "sprite");
+	    set_colour(WINTITLE);
+	    DrawScreenText(ix0, iy0, "Linedef #%d", obj_no);
+	    set_colour(WINFG);
+	    DrawScreenText(-1, iy0 + (int) (1.5 * FONTH),
+			   "\1Flags:\2    %.19s",
+			   GetLineDefFlagsName(LineDefs[obj_no].flags));
+	    DrawScreenText(-1, -1, "\1Type:\2 %3d %.19s",
+			   LineDefs[obj_no].type,
+			   GetLineDefTypeName(LineDefs[obj_no].type));
+	    {
+		int tag = LineDefs[obj_no].tag;
+		int first_sector = NumSectors;
+		int second_sector = NumSectors;
+		if (tag != 0)
+		{
+		    for (int n = 0; n < NumSectors; n++)
+			if (Sectors[n].tag == tag)
+			{
+			    if (first_sector >= NumSectors)
+				first_sector = n;
+			    else
+			    {
+				second_sector = n;
+				break;
+			    }
+			}
+		}
+		if (first_sector < NumSectors && second_sector < NumSectors)
+		    DrawScreenText(-1, -1, "\1Tag:\2      %d (#%d+)", tag,
+				   first_sector);
+		else if (first_sector < NumSectors)
+		    DrawScreenText(-1, -1, "\1Tag:\2      %d (#%d)", tag,
+				   first_sector);
+		else
+		    DrawScreenText(-1, -1, "\1Tag:\2      %d (none)", tag);
+	    }
+	    s1 = LineDefs[obj_no].start;
+	    s2 = LineDefs[obj_no].end;
+	    DrawScreenText(-1, -1, "\1Vertices:\2 (#%d, #%d)", s1, s2);
+	    n = ComputeDist(Vertices[s2].x - Vertices[s1].x,
+			    Vertices[s2].y - Vertices[s1].y);
+	    DrawScreenText(-1, -1, "\1Length:\2   %d", n);
+	    sd1 = LineDefs[obj_no].sidedef1;
+	    sd2 = LineDefs[obj_no].sidedef2;
+	    DrawScreenText(-1, -1, "\1" "1st sd:\2   #%d", sd1);
+	    DrawScreenText(-1, -1, "\1" "2nd sd:\2   #%d", sd2);
+	    if (sd1 >= 0)
+		s1 = SideDefs[sd1].sector;
+	    else
+		s1 = -1;
+	    if (sd2 >= 0)
+		s2 = SideDefs[sd2].sector;
+	    else
+		s2 = -1;
+	}
+	else
+	{
+	    const char *message = "(no linedef selected)";
+	    set_colour(WINFG_DIM);
+	    DrawScreenText(x0 + (width - FONTW * strlen(message)) / 2,
+			   y0 + (height - FONTH) / 2, message);
+	}
+
+	// 1st sidedef
+	x0 += width;
+	width = 2 * BOX_BORDER + 2 * WIDE_HSPACING + 16 * FONTW;
+	ix0 = x0 + BOX_BORDER + WIDE_HSPACING;
+	y0 = out_y1 - height + 1;
+	// Ignore box_disp -- always redraw the whole box
+	DrawScreenBox3D(x0, y0, x0 + width - 1, y0 + height - 1);
+	if (obj_no >= 0 && sd1 >= 0)
+	{
+	    set_colour(WINTITLE);
+	    DrawScreenText(ix0, iy0, "Sidedef1 #%d", sd1);
+
+	    if (s1 >= 0 && s2 >= 0 && Sectors[s1].ceilh > Sectors[s2].ceilh
+		&& !(is_sky(Sectors[s1].ceilt) && is_sky(Sectors[s2].ceilt)))
+	    {
+		if (SideDefs[sd1].tex1[0] == '-'
+		    && SideDefs[sd1].tex1[1] == '\0')
+		    set_colour(CLR_ERROR);
+		else
+		    set_colour(WINFG);
+	    }
+	    else
+		set_colour(WINFG_DIM);
+	    DrawScreenText(-1, iy0 + (int) (1.5 * FONTH), "\1Upper:\2  %.*s",
+			   WAD_TEX_NAME, SideDefs[sd1].tex1);
+
+	    if (sd2 < 0
+		&& SideDefs[sd1].tex3[0] == '-'
+		&& SideDefs[sd1].tex3[1] == '\0')
+		set_colour(CLR_ERROR);
+	    else
+		set_colour(WINFG);
+	    DrawScreenText(-1, -1,
+			   "\1Middle:\2 %.*s", WAD_TEX_NAME,
+			   SideDefs[sd1].tex3);
+
+	    if (s1 >= 0 && s2 >= 0 && Sectors[s1].floorh < Sectors[s2].floorh
+		&& !(is_sky(Sectors[s1].floort)
+		     && is_sky(Sectors[s2].floort)))
+	    {
+		if (SideDefs[sd1].tex2[0] == '-'
+		    && SideDefs[sd1].tex2[1] == '\0')
+		    set_colour(CLR_ERROR);
+		else
+		    set_colour(WINFG);
+	    }
+	    else
+		set_colour(WINFG_DIM);
+	    DrawScreenText(-1, -1, "\1Lower:\2  %.*s",
+			   WAD_TEX_NAME, SideDefs[sd1].tex2);
+
+	    set_colour(WINFG);
+	    DrawScreenText(-1, -1, "\1X-ofs:\2  %d", SideDefs[sd1].xoff);
+	    DrawScreenText(-1, -1, "\1Y-ofs:\2  %d", SideDefs[sd1].yoff);
+	    DrawScreenText(-1, -1, "\1Sector:\2 #%d", s1);
 	}
 	else
 	{
-	  Lump_loc loc;
-	  Img img (sprite_width, sprite_height, false);
-	  Sticker sticker;
-	  wad_res.sprites.loc_by_root (sprite_root, loc);
-	  if (loc.wad == 0
-	    || LoadPicture (img, sprite_root, loc, INT_MIN, INT_MIN))
-	  {
-	    push_colour (WINBG);
-	    DrawScreenBox (sx0, sy0, sx1, sy1);
-	    pop_colour ();
-	    set_colour (CLR_ERROR);
-	    DrawScreenString (
-	      sx0 + (sprite_width - strlen (sprite_root) * FONTW) / 2,
-	      sy0 + sprite_height / 2 + 1 - 3 * FONTH / 2, sprite_root);
-	    DrawScreenText (
-	      sx0 + (sprite_width - 3 * FONTW) / 2,
-	      sy0 + sprite_height / 2 + 1 - FONTH / 2, "not");
-	    DrawScreenText (
-	      sx0 + (sprite_width - 5 * FONTW) / 2,
-	      sy0 + sprite_height / 2 + 1 + FONTH / 2, "found");
-	  }
-	  else
-	  {
-	    if (flags & THINGDEF_SPECTRAL)
-	      spectrify_img (img);
-	    sticker.load (img, true);
-	    sticker.draw (drw, 't', sx0, sy0);
-	  }
-	}
-      }
-    }
-    break;
-
-    case OBJ_LINEDEFS:
-      // Linedef
-      width  = 2 * BOX_BORDER + 2 * WIDE_HSPACING + 29 * FONTW;
-      height = 2 * BOX_BORDER + 2 * WIDE_VSPACING + (int) (8.5 * FONTH);
-      x0 = 0;
-      y0 = out_y1 - height + 1;
-      ix0 = x0 + BOX_BORDER + WIDE_HSPACING;
-      iy0 = y0 + BOX_BORDER + WIDE_VSPACING;
-      // Ignore box_disp -- always redraw the whole box
-      DrawScreenBox3D (x0, y0, x0 + width - 1, y0 + height - 1);
-      if (obj_no >= 0)
-      {
-	set_colour (WINTITLE);
-	DrawScreenText (ix0, iy0, "Linedef #%d", obj_no);
-	set_colour (WINFG);
-	DrawScreenText (-1, iy0 + (int) (1.5 * FONTH),
-			"\1Flags:\2    %.19s",
-			GetLineDefFlagsName (LineDefs[obj_no].flags));
-	DrawScreenText (-1, -1, "\1Type:\2 %3d %.19s",
-			LineDefs[obj_no].type,
-			GetLineDefTypeName (LineDefs[obj_no].type));
-	{
-	  int tag           = LineDefs[obj_no].tag;
-	  int first_sector  = NumSectors;
-	  int second_sector = NumSectors;
-	  if (tag != 0)
-	  {
-	    for (int n = 0; n < NumSectors; n++)
-	      if (Sectors[n].tag == tag)
-	      {
-		if (first_sector >= NumSectors)
-		  first_sector = n;
-		else
-		{
-		  second_sector = n;
-		  break;
-		}
-	      }
-	  }
-	  if (first_sector < NumSectors && second_sector < NumSectors)
-	    DrawScreenText (-1, -1, "\1Tag:\2      %d (#%d+)", tag, first_sector);
-	  else if (first_sector < NumSectors)
-	    DrawScreenText (-1, -1, "\1Tag:\2      %d (#%d)", tag, first_sector);
-	  else
-	    DrawScreenText (-1, -1, "\1Tag:\2      %d (none)", tag);
+	    const char *message = "(no 1st sidedef)";
+	    set_colour(CLR_ERROR);
+	    DrawScreenText(x0 + (width - FONTW * strlen(message)) / 2,
+			   y0 + (height - FONTH) / 2, message);
 	}
-	s1 = LineDefs[obj_no].start;
-	s2 = LineDefs[obj_no].end;
-	DrawScreenText (-1, -1, "\1Vertices:\2 (#%d, #%d)", s1, s2);
-	n = ComputeDist (Vertices[s2].x - Vertices[s1].x,
-			 Vertices[s2].y - Vertices[s1].y);
-	DrawScreenText (-1, -1, "\1Length:\2   %d", n);
-	sd1 = LineDefs[obj_no].sidedef1;
-	sd2 = LineDefs[obj_no].sidedef2;
-	DrawScreenText (-1, -1, "\1" "1st sd:\2   #%d", sd1);
-	DrawScreenText (-1, -1, "\1" "2nd sd:\2   #%d", sd2);
-	if (sd1 >= 0)
-	  s1 = SideDefs[sd1].sector;
-	else
-	  s1 = -1;
-	if (sd2 >= 0)
-	  s2 = SideDefs[sd2].sector;
-	else
-	  s2 = -1;
-      }
-      else
-      {
-	const char *message = "(no linedef selected)";
-	set_colour (WINFG_DIM);
-	DrawScreenText (x0 + (width - FONTW * strlen (message)) / 2,
-	  y0 + (height - FONTH) / 2, message);
-      }
 
-      // 1st sidedef
-      x0 += width;
-      width  = 2 * BOX_BORDER + 2 * WIDE_HSPACING + 16 * FONTW;
-      ix0 = x0 + BOX_BORDER + WIDE_HSPACING;
-      y0 = out_y1 - height + 1;
-      // Ignore box_disp -- always redraw the whole box
-      DrawScreenBox3D (x0, y0, x0 + width - 1, y0 + height - 1);
-      if (obj_no >= 0 && sd1 >= 0)
-      {
-	set_colour (WINTITLE);
-	DrawScreenText (ix0, iy0, "Sidedef1 #%d", sd1);
-
-	if (s1 >= 0 && s2 >= 0 && Sectors[s1].ceilh > Sectors[s2].ceilh
-	  && ! (is_sky (Sectors[s1].ceilt) && is_sky (Sectors[s2].ceilt)))
-	{
-	  if (SideDefs[sd1].tex1[0] == '-' && SideDefs[sd1].tex1[1] == '\0')
-	    set_colour (CLR_ERROR);
-	  else
-	    set_colour (WINFG);
-	}
-	else
-	  set_colour (WINFG_DIM);
-	DrawScreenText (-1, iy0 + (int) (1.5 * FONTH), "\1Upper:\2  %.*s",
-	    WAD_TEX_NAME, SideDefs[sd1].tex1);
-
-	if (sd2 < 0
-	  && SideDefs[sd1].tex3[0] == '-' && SideDefs[sd1].tex3[1] == '\0')
-	  set_colour (CLR_ERROR);
-	else
-	  set_colour (WINFG);
-	DrawScreenText (-1, -1,
-	  "\1Middle:\2 %.*s", WAD_TEX_NAME, SideDefs[sd1].tex3);
-
-	if (s1 >= 0 && s2 >= 0 && Sectors[s1].floorh < Sectors[s2].floorh
-	  && ! (is_sky (Sectors[s1].floort) && is_sky (Sectors[s2].floort)))
+	// 2nd sidedef
+	x0 += width;
+	ix0 = x0 + BOX_BORDER + WIDE_HSPACING;
+	y0 = out_y1 - height + 1;
+	// Ignore box_disp -- always redraw the whole box
+	DrawScreenBox3D(x0, y0, x0 + width - 1, y0 + height - 1);
+	if (obj_no >= 0 && sd2 >= 0)
 	{
-	  if (SideDefs[sd1].tex2[0] == '-' && SideDefs[sd1].tex2[1] == '\0')
-	    set_colour (CLR_ERROR);
-	  else
-	    set_colour (WINFG);
-	}
-	else
-	  set_colour (WINFG_DIM);
-	DrawScreenText (-1, -1, "\1Lower:\2  %.*s",
-	  WAD_TEX_NAME, SideDefs[sd1].tex2);
+	    set_colour(WINTITLE);
+	    DrawScreenText(ix0, iy0, "Sidedef2 #%d", sd2);
+	    set_colour(WINFG);
+	    const char *tex_name;
 
-	set_colour (WINFG);
-	DrawScreenText (-1, -1, "\1X-ofs:\2  %d", SideDefs[sd1].xoff);
-	DrawScreenText (-1, -1, "\1Y-ofs:\2  %d", SideDefs[sd1].yoff);
-	DrawScreenText (-1, -1, "\1Sector:\2 #%d", s1);
-      }
-      else
-      {
-	const char *message = "(no 1st sidedef)";
-	set_colour (CLR_ERROR);
-	DrawScreenText (x0 + (width - FONTW * strlen (message)) / 2,
-	  y0 + (height - FONTH) / 2, message);
-      }
+	    tex_name = SideDefs[sd2].tex1;	// Upper texture
+	    if (s1 >= 0 && s2 >= 0 && Sectors[s2].ceilh > Sectors[s1].ceilh
+		&& !(is_sky(Sectors[s1].ceilt) && is_sky(Sectors[s2].ceilt)))
+	    {
+		if (tex_name[0] == '-' && tex_name[1] == '\0')
+		    set_colour(CLR_ERROR);
+		else
+		    set_colour(WINFG);
+	    }
+	    else
+		set_colour(WINFG_DIM);
+	    DrawScreenText(-1, iy0 + (int) (1.5 * FONTH),
+			   "\1Upper:\2  %.*s", WAD_TEX_NAME, tex_name);
 
-      // 2nd sidedef
-      x0 += width;
-      ix0 = x0 + BOX_BORDER + WIDE_HSPACING;
-      y0 = out_y1 - height + 1;
-      // Ignore box_disp -- always redraw the whole box
-      DrawScreenBox3D (x0, y0, x0 + width - 1, y0 + height - 1);
-      if (obj_no >= 0 && sd2 >= 0)
-      {
-	set_colour (WINTITLE);
-	DrawScreenText (ix0, iy0, "Sidedef2 #%d", sd2);
-	set_colour (WINFG);
-	const char *tex_name;
+	    tex_name = SideDefs[sd2].tex3;	// Middle texture
+	    set_colour(WINFG);
+	    DrawScreenText(-1, -1,
+			   "\1Middle:\2 %.*s", WAD_TEX_NAME, tex_name);
 
-	tex_name = SideDefs[sd2].tex1;  // Upper texture
-	if (s1 >= 0 && s2 >= 0 && Sectors[s2].ceilh > Sectors[s1].ceilh
-	  && ! (is_sky (Sectors[s1].ceilt) && is_sky (Sectors[s2].ceilt)))
-	{
-	  if (tex_name[0] == '-' && tex_name[1] == '\0')
-	    set_colour (CLR_ERROR);
-	  else
-	    set_colour (WINFG);
-	}
-	else
-	  set_colour (WINFG_DIM);
-	DrawScreenText (-1, iy0 + (int) (1.5 * FONTH),
-	  "\1Upper:\2  %.*s", WAD_TEX_NAME, tex_name);
+	    tex_name = SideDefs[sd2].tex2;	// Lower texture
+	    if (s1 >= 0 && s2 >= 0 && Sectors[s2].floorh < Sectors[s1].floorh
+		&& !(is_sky(Sectors[s1].floort)
+		     && is_sky(Sectors[s2].floort)))
+	    {
+		if (tex_name[0] == '-' && tex_name[1] == '\0')
+		    set_colour(CLR_ERROR);
+		else
+		    set_colour(WINFG);
+	    }
+	    else
+		set_colour(WINFG_DIM);
+	    DrawScreenText(-1, -1, "\1Lower:\2  %.*s", WAD_TEX_NAME,
+			   tex_name);
 
-	tex_name = SideDefs[sd2].tex3;  // Middle texture
-	set_colour (WINFG);
-	DrawScreenText (-1, -1,
-	  "\1Middle:\2 %.*s", WAD_TEX_NAME, tex_name);
-
-	tex_name = SideDefs[sd2].tex2;  // Lower texture
-	if (s1 >= 0 && s2 >= 0 && Sectors[s2].floorh < Sectors[s1].floorh
-	  && ! (is_sky (Sectors[s1].floort) && is_sky (Sectors[s2].floort)))
-	{
-	  if (tex_name[0] == '-' && tex_name[1] == '\0')
-	    set_colour (CLR_ERROR);
-	  else
-	    set_colour (WINFG);
+	    set_colour(WINFG);
+	    DrawScreenText(-1, -1, "\1X-ofs:\2  %d", SideDefs[sd2].xoff);
+	    DrawScreenText(-1, -1, "\1Y-ofs:\2  %d", SideDefs[sd2].yoff);
+	    DrawScreenText(-1, -1, "\1Sector:\2 #%d", s2);
 	}
 	else
-	  set_colour (WINFG_DIM);
-	DrawScreenText (-1, -1, "\1Lower:\2  %.*s", WAD_TEX_NAME, tex_name);
+	{
+	    const char *message = "(no 2nd sidedef)";
+	    // If the "2" flag is set, there must be a second sidedef
+	    if (LineDefs[obj_no].flags & 0x04)	// FIXME hard-coded
+		set_colour(CLR_ERROR);
+	    else
+		set_colour(WINFG_DIM);
+	    DrawScreenText(x0 + (width - FONTW * strlen(message)) / 2,
+			   y0 + (height - FONTH) / 2, message);
+	}
 
-	set_colour (WINFG);
-	DrawScreenText (-1, -1, "\1X-ofs:\2  %d", SideDefs[sd2].xoff);
-	DrawScreenText (-1, -1, "\1Y-ofs:\2  %d", SideDefs[sd2].yoff);
-	DrawScreenText (-1, -1, "\1Sector:\2 #%d", s2);
-      }
-      else
-      {
-	const char *message = "(no 2nd sidedef)";
-	// If the "2" flag is set, there must be a second sidedef
-	if (LineDefs[obj_no].flags & 0x04)  // FIXME hard-coded
-	  set_colour (CLR_ERROR);
-	else
-	  set_colour (WINFG_DIM);
-	DrawScreenText (x0 + (width - FONTW * strlen (message)) / 2,
-	  y0 + (height - FONTH) / 2, message);
-      }
-
-      // Superimposed linedefs
-      {
-	Superimposed_ld super;
-	super.set (obj_no);
-	obj_no_t l = super.get ();
-	int iy1;
-
-	if (l != -1 || box_disp[3])
+	// Superimposed linedefs
 	{
-	  x0 += width;
-	  width  = 2 * BOX_BORDER + 2 * WIDE_HSPACING + 12 * FONTW;
-	  ix0 = x0 + BOX_BORDER + WIDE_HSPACING;
-	  iy0 = y0 + BOX_BORDER + WIDE_VSPACING;
-	  iy1 = y0 + height - 1 - BOX_BORDER - WIDE_VSPACING;
-	  DrawScreenBox3D (x0, y0, x0 + width - 1, y0 + height - 1);
+	    Superimposed_ld super;
+	    super.set(obj_no);
+	    obj_no_t l = super.get();
+	    int iy1;
+
+	    if (l != -1 || box_disp[3])
+	    {
+		x0 += width;
+		width = 2 * BOX_BORDER + 2 * WIDE_HSPACING + 12 * FONTW;
+		ix0 = x0 + BOX_BORDER + WIDE_HSPACING;
+		iy0 = y0 + BOX_BORDER + WIDE_VSPACING;
+		iy1 = y0 + height - 1 - BOX_BORDER - WIDE_VSPACING;
+		DrawScreenBox3D(x0, y0, x0 + width - 1, y0 + height - 1);
+	    }
+	    if (l != -1)
+	    {
+		box_disp[3] = true;
+		set_colour(WINTITLE);
+		DrawScreenString(ix0, iy0, "Superimposed");
+		set_colour(WINFG);
+		iy0 += int (1.5 * FONTH);
+		while (l != -1)
+		{
+		    if (iy0 + FONTH - 1 <= iy1)
+			DrawScreenText(ix0, iy0, "#%d", l);
+		    /* Too many linedefs, replace the last one by "(more)".
+		       Not elegant, but it makes the code simpler. */
+		    else
+		    {
+			iy0 -= FONTH;
+			set_colour(WINBG);
+			DrawScreenBox(ix0, iy0, ix0 + 12 * FONTW - 1,
+				      iy0 + FONTH - 1);
+			set_colour(WINFG);
+			DrawScreenString(ix0, iy0, "(more)");
+			break;
+		    }
+		    iy0 += FONTH;
+		    l = super.get();
+		}
+	    }
 	}
-	if (l != -1)
-	{
-	  box_disp[3] = true;
-	  set_colour (WINTITLE);
-	  DrawScreenString (ix0, iy0, "Superimposed");
-	  set_colour (WINFG);
-	  iy0 += int (1.5 * FONTH);
-	  while (l != -1)
-	  {
-	    if (iy0 + FONTH - 1 <= iy1)
-	      DrawScreenText (ix0, iy0, "#%d", l);
-	    /* Too many linedefs, replace the last one by "(more)".
-	       Not elegant, but it makes the code simpler. */
-	    else
-	    {
-	      iy0 -= FONTH;
-	      set_colour (WINBG);
-	      DrawScreenBox (ix0, iy0, ix0 + 12 * FONTW - 1, iy0 + FONTH - 1);
-	      set_colour (WINFG);
-	      DrawScreenString (ix0, iy0, "(more)");
-	      break;
-	    }
-	    iy0 += FONTH;
-	    l = super.get ();
-	  }
-	}
-      }
-      break;
+	break;
 
     case OBJ_VERTICES:
-      width  = 2 * BOX_BORDER + 2 * WIDE_HSPACING + 29 * FONTW;
-      height = 2 * BOX_BORDER + 2 * WIDE_VSPACING + (int) (2.5 * FONTH);
-      x0 = 0;
-      y0 = out_y1 - height + 1;
-      ix0 = x0 + BOX_BORDER + WIDE_HSPACING;
-      iy0 = y0 + BOX_BORDER + WIDE_VSPACING;
-      // Ignore box_disp -- always redraw the whole box
-      DrawScreenBox3D (x0, y0, x0 + width - 1, y0 + height - 1);
-      if (obj_no < 0)
-      {
-	const char *message = "(no vertex selected)";
-	set_colour (WINFG_DIM);
-	DrawScreenText (x0 + (width - FONTW * strlen (message)) / 2,
-	  y0 + (height - FONTH) / 2, message);
+	width = 2 * BOX_BORDER + 2 * WIDE_HSPACING + 29 * FONTW;
+	height = 2 * BOX_BORDER + 2 * WIDE_VSPACING + (int) (2.5 * FONTH);
+	x0 = 0;
+	y0 = out_y1 - height + 1;
+	ix0 = x0 + BOX_BORDER + WIDE_HSPACING;
+	iy0 = y0 + BOX_BORDER + WIDE_VSPACING;
+	// Ignore box_disp -- always redraw the whole box
+	DrawScreenBox3D(x0, y0, x0 + width - 1, y0 + height - 1);
+	if (obj_no < 0)
+	{
+	    const char *message = "(no vertex selected)";
+	    set_colour(WINFG_DIM);
+	    DrawScreenText(x0 + (width - FONTW * strlen(message)) / 2,
+			   y0 + (height - FONTH) / 2, message);
+	    break;
+	}
+	set_colour(WINTITLE);
+	DrawScreenText(ix0, iy0, "Vertex #%d", obj_no);
+	set_colour(WINFG);
+	DrawScreenText(-1, iy0 + (int) (1.5 * FONTH),
+		       "\1Coordinates:\2 (%d, %d)", Vertices[obj_no].x,
+		       Vertices[obj_no].y);
 	break;
-      }
-      set_colour (WINTITLE);
-      DrawScreenText (ix0, iy0, "Vertex #%d", obj_no);
-      set_colour (WINFG);
-      DrawScreenText (-1, iy0 + (int) (1.5 * FONTH),
-	"\1Coordinates:\2 (%d, %d)", Vertices[obj_no].x, Vertices[obj_no].y);
-      break;
 
     case OBJ_SECTORS:
-    {
-      int x1, y1;
-      int ix1, iy1;
-      const int columns = 24;
-      width  = BOX_BORDER
-	     + WIDE_HSPACING
-	     + columns * FONTW
-	     + WIDE_HSPACING
-	     + HOLLOW_BORDER
-	     + DOOM_FLAT_WIDTH
-	     + HOLLOW_BORDER
-	     + WIDE_HSPACING
-	     + BOX_BORDER;
-      height = 2 * BOX_BORDER
-	     + 2 * WIDE_VSPACING
-	     + y_max ((unsigned) (9.5 * FONTH),
-		    WIDE_HSPACING + 4 * HOLLOW_BORDER + 2 * DOOM_FLAT_HEIGHT);
-      x0 = 0;
-      y0 = out_y1 - height + 1;
-      x1 = x0 + width - 1;
-      y1 = y0 + height - 1;
-      ix0 = x0 + BOX_BORDER + WIDE_HSPACING;
-      iy0 = y0 + BOX_BORDER + WIDE_VSPACING;
-      ix1 = x1 - BOX_BORDER - WIDE_HSPACING;
-      iy1 = y1 - BOX_BORDER - WIDE_VSPACING;
-      if (box_disp[0])
-      {
-	push_colour (WINBG);
-	DrawScreenBox (ix0, iy0, ix0 + columns * FONTW - 1, iy1);
-	pop_colour ();
-      }
-      else
-	DrawScreenBox3D (x0, y0, x1, y1);
-      if (obj_no < 0)
-      {
-	const char *const message = "(no sector selected)";
-	set_colour (WINFG_DIM);
-	DrawScreenText (x0 + (width - FONTW * strlen (message)) / 2,
-	  y0 + (height - FONTH) / 2, message);
-	break;
-      }
-      set_colour (WINTITLE);
-      DrawScreenText (ix0, iy0, "Sector #%d", obj_no);
-      set_colour (WINFG);
-      const struct Sector *sec = Sectors + obj_no;
-      if (prev_sector >= 0 && prev_sector != obj_no)
-      {
-	DrawScreenText (-1, iy0 + (int) (1.5 * FONTH),
-	  "\1Floor:\2    %d (%+d)",
-	  sec->floorh, sec->floorh - prev_floorh);
-	DrawScreenText (-1, -1, "\1Ceiling:\2  %d (%+d)",
-	  sec->ceilh, sec->ceilh - prev_ceilh);
-      }
-      else
-      {
-	DrawScreenText (-1, iy0 + (int) (1.5 * FONTH),
-	  "\1Floor:\2    %d",   sec->floorh);
-        DrawScreenText (-1, -1, "\1Ceiling:\2  %d",  sec->ceilh);
-      }
-      DrawScreenText (-1, -1, "\1Headroom:\2 %d",   sec->ceilh - sec->floorh);
-      DrawScreenText (-1, -1, "\1Floor:\2    %.*s", WAD_FLAT_NAME, sec->floort);
-      DrawScreenText (-1, -1, "\1Ceiling:\2  %.*s", WAD_FLAT_NAME, sec->ceilt);
-      DrawScreenText (-1, -1, "\1Light:\2    %d",   sec->light);
-      DrawScreenText (-1, -1, "\1Type:\2 %3d %.14s",
-	sec->special, GetSectorTypeName (sec->special));
-      {
-	int tag       = sec->tag;
-	int first_ld  = NumLineDefs;
-	int second_ld = NumLineDefs;
-
-	if (tag != 0)
 	{
-	  for (n = 0; n < NumLineDefs; n++)
-	    if (LineDefs[n].tag == tag)
+	    int x1, y1;
+	    int ix1, iy1;
+	    const int columns = 24;
+	    width = BOX_BORDER
+		+ WIDE_HSPACING
+		+ columns * FONTW
+		+ WIDE_HSPACING
+		+ HOLLOW_BORDER
+		+ DOOM_FLAT_WIDTH
+		+ HOLLOW_BORDER + WIDE_HSPACING + BOX_BORDER;
+	    height = 2 * BOX_BORDER
+		+ 2 * WIDE_VSPACING
+		+ y_max((unsigned) (9.5 * FONTH),
+			WIDE_HSPACING + 4 * HOLLOW_BORDER +
+			2 * DOOM_FLAT_HEIGHT);
+	    x0 = 0;
+	    y0 = out_y1 - height + 1;
+	    x1 = x0 + width - 1;
+	    y1 = y0 + height - 1;
+	    ix0 = x0 + BOX_BORDER + WIDE_HSPACING;
+	    iy0 = y0 + BOX_BORDER + WIDE_VSPACING;
+	    ix1 = x1 - BOX_BORDER - WIDE_HSPACING;
+	    iy1 = y1 - BOX_BORDER - WIDE_VSPACING;
+	    if (box_disp[0])
 	    {
-	      if (first_ld >= NumLineDefs)
-		first_ld = n;
-	      else
-	      {
-		second_ld = n;
-		break;
-	      }
+		push_colour(WINBG);
+		DrawScreenBox(ix0, iy0, ix0 + columns * FONTW - 1, iy1);
+		pop_colour();
 	    }
-	}
-	if (first_ld < NumLineDefs && second_ld < NumLineDefs)
-	   DrawScreenText (-1, -1, "\1Tag:\2      %d (#%d+)", tag, first_ld);
-	else if (first_ld < NumLineDefs)
-	   DrawScreenText (-1, -1, "\1Tag:\2      %d (#%d)", tag, first_ld);
-	else if (tag == 99 || tag == 999)
-	   DrawScreenText (-1, -1, "\1Tag:\2      %d (stairs?)", tag);
-	else if (tag == 666)
-	   DrawScreenText (-1, -1, "\1Tag:\2      %d (lower@end)", tag);
-	else if (tag == 667)
-	   DrawScreenText (-1, -1, "\1Tag:\2      %d (raise@end)", tag);
-	else
-	   DrawScreenText (-1, -1, "\1Tag:\2      %d (none)", tag);
-      }
-      {
-	hookfunc_comm_t block;
-
-	// Display the floor texture in the bottom right corner
-	block.x1 = ix1;
-	block.x0 = block.x1 - (DOOM_FLAT_WIDTH + 2 * HOLLOW_BORDER - 1);
-	block.y1 = iy1;
-	block.y0 = block.y1 - (DOOM_FLAT_HEIGHT + 2 * HOLLOW_BORDER - 1);
-	block.name = sec->floort;
-	display_flat_depressed (&block);
-
-	// Display the ceiling texture above the floor texture
-	block.y1 = block.y0 - (WIDE_VSPACING + 1);
-	block.y0 = block.y1 - (DOOM_FLAT_HEIGHT + 2 * HOLLOW_BORDER - 1);
-	block.name = sec->ceilt;
-	display_flat_depressed (&block);
-      }
-
-      // Show all EDGE extrafloors for this sector
-      {
-	x0 += width;
-	const int columns2 = 16;
-	const int width2   = BOX_BORDER
-			   + WIDE_HSPACING
-			   + columns2 * FONTW
-			   + WIDE_HSPACING
-			   + HOLLOW_BORDER
-			   + DOOM_FLAT_WIDTH
-			   + HOLLOW_BORDER
-			   + WIDE_HSPACING
-			   + BOX_BORDER;
-	std::vector<Extraf> v;
-	get_extrafloors (v, sec->tag);
-	size_t e;
-	for (e = 0; e < v.size () && e + 1 < MAX_BOXES; e++, x0 += width2)
-	{
-	  const Extraf& i = v[e];
-	  obj_no_t dsecno = i.sector;
-	  bool thick = (*i.tex != '\0');
-	  const struct Sector *dsec = Sectors + dsecno;
-	  x1 = x0 + width2 - 1;
-	  y1 = y0 + height - 1;
-	  ix0 = x0 + BOX_BORDER + WIDE_HSPACING;
-	  iy0 = y0 + BOX_BORDER + WIDE_VSPACING;
-	  ix1 = x1 - BOX_BORDER - WIDE_HSPACING;
-	  iy1 = y1 - BOX_BORDER - WIDE_VSPACING;
-	  if (box_disp[e + 1])  // FIXME
-	  {
-	    push_colour (WINBG);
-	    DrawScreenBox (ix0, iy0, ix0 + columns2 * FONTW - 1, iy1);
-	    pop_colour ();
-	  }
-	  else
-	  {
-	    DrawScreenBox3D (x0, y0, x1, y1);
-	    box_disp[e + 1] = true;
-	  }
-	  if (! is_sector (dsecno))  // Can't happen
-	    continue;
-	  set_colour (WINTITLE);
-	  if (thick)
-	    DrawScreenText (ix0, iy0, "Thick #%d", dsecno);
-	  else
-	    DrawScreenText (ix0, iy0, "Thin #%d", dsecno);
-	  set_colour (WINFG);
-	  if (thick)
-	  {
-	    DrawScreenText (-1, iy0 + (int) (1.5 * FONTH),
-				    "\1Bottom:\2 %d",   dsec->floorh);
-	    DrawScreenText (-1, -1, "\1Top:\2    %d",   dsec->ceilh);
-	    DrawScreenText (-1, -1, "\1Thick:\2  %d",   dsec->ceilh - dsec->floorh);
-	    DrawScreenText (-1, -1, "\1Bottom:\2 %.*s", WAD_FLAT_NAME,dsec->floort);
-	    DrawScreenText (-1, -1, "\1Top:\2    %.*s", WAD_FLAT_NAME, dsec->ceilt);
-	  }
-	  else
-	  {
-	    DrawScreenText (-1, iy0 + (int) (1.5 * FONTH),
-				    "\1Height:\2 %d",   dsec->floorh);
-	    DrawScreenText (-1, -1, "\1Flat:\2   %.*s", WAD_FLAT_NAME,dsec->floort);
-	  }
-	  DrawScreenText (-1, -1, "\1Shadow:\2 %d",   dsec->light);
-	  DrawScreenText (-1, -1, "\1Type:\2   %d",   dsec->special);
-	  if (thick)
-	    DrawScreenText (-1, -1, "\1Side:\2   %.*s", WAD_TEX_NAME, i.tex);
-	  {
-	    hookfunc_comm_t block;
-
-	    // Display the top texture in the bottom right corner
-	    block.x1 = ix1;
-	    block.x0 = block.x1 - (DOOM_FLAT_WIDTH + 2 * HOLLOW_BORDER - 1);
-	    block.y1 = iy1;
-	    block.y0 = block.y1 - (DOOM_FLAT_HEIGHT + 2 * HOLLOW_BORDER - 1);
-	    block.name = dsec->floort;
-	    display_flat_depressed (&block);
-
-	    // Display the bottom texture above the floor texture
-	    block.y1 = block.y0 - (WIDE_VSPACING + 1);
-	    block.y0 = block.y1 - (DOOM_FLAT_HEIGHT + 2 * HOLLOW_BORDER - 1);
-	    if (thick)
+	    else
+		DrawScreenBox3D(x0, y0, x1, y1);
+	    if (obj_no < 0)
 	    {
-	      block.name = dsec->ceilt;
-	      display_flat_depressed (&block);
+		const char *const message = "(no sector selected)";
+		set_colour(WINFG_DIM);
+		DrawScreenText(x0 + (width - FONTW * strlen(message)) / 2,
+			       y0 + (height - FONTH) / 2, message);
+		break;
+	    }
+	    set_colour(WINTITLE);
+	    DrawScreenText(ix0, iy0, "Sector #%d", obj_no);
+	    set_colour(WINFG);
+	    const struct Sector *sec = Sectors + obj_no;
+	    if (prev_sector >= 0 && prev_sector != obj_no)
+	    {
+		DrawScreenText(-1, iy0 + (int) (1.5 * FONTH),
+			       "\1Floor:\2    %d (%+d)",
+			       sec->floorh, sec->floorh - prev_floorh);
+		DrawScreenText(-1, -1, "\1Ceiling:\2  %d (%+d)",
+			       sec->ceilh, sec->ceilh - prev_ceilh);
 	    }
 	    else
 	    {
-	      push_colour (WINBG);
-	      DrawScreenBoxwh (block.x0, block.y0, DOOM_FLAT_WIDTH
-	        + 2 * HOLLOW_BORDER, DOOM_FLAT_HEIGHT + 2 * HOLLOW_BORDER);
-	      pop_colour ();
+		DrawScreenText(-1, iy0 + (int) (1.5 * FONTH),
+			       "\1Floor:\2    %d", sec->floorh);
+		DrawScreenText(-1, -1, "\1Ceiling:\2  %d", sec->ceilh);
+	    }
+	    DrawScreenText(-1, -1, "\1Headroom:\2 %d",
+			   sec->ceilh - sec->floorh);
+	    DrawScreenText(-1, -1, "\1Floor:\2    %.*s", WAD_FLAT_NAME,
+			   sec->floort);
+	    DrawScreenText(-1, -1, "\1Ceiling:\2  %.*s", WAD_FLAT_NAME,
+			   sec->ceilt);
+	    DrawScreenText(-1, -1, "\1Light:\2    %d", sec->light);
+	    DrawScreenText(-1, -1, "\1Type:\2 %3d %.14s",
+			   sec->special, GetSectorTypeName(sec->special));
+	    {
+		int tag = sec->tag;
+		int first_ld = NumLineDefs;
+		int second_ld = NumLineDefs;
+
+		if (tag != 0)
+		{
+		    for (n = 0; n < NumLineDefs; n++)
+			if (LineDefs[n].tag == tag)
+			{
+			    if (first_ld >= NumLineDefs)
+				first_ld = n;
+			    else
+			    {
+				second_ld = n;
+				break;
+			    }
+			}
+		}
+		if (first_ld < NumLineDefs && second_ld < NumLineDefs)
+		    DrawScreenText(-1, -1, "\1Tag:\2      %d (#%d+)", tag,
+				   first_ld);
+		else if (first_ld < NumLineDefs)
+		    DrawScreenText(-1, -1, "\1Tag:\2      %d (#%d)", tag,
+				   first_ld);
+		else if (tag == 99 || tag == 999)
+		    DrawScreenText(-1, -1, "\1Tag:\2      %d (stairs?)", tag);
+		else if (tag == 666)
+		    DrawScreenText(-1, -1, "\1Tag:\2      %d (lower@end)",
+				   tag);
+		else if (tag == 667)
+		    DrawScreenText(-1, -1, "\1Tag:\2      %d (raise@end)",
+				   tag);
+		else
+		    DrawScreenText(-1, -1, "\1Tag:\2      %d (none)", tag);
+	    }
+	    {
+		hookfunc_comm_t block;
+
+		// Display the floor texture in the bottom right corner
+		block.x1 = ix1;
+		block.x0 =
+		    block.x1 - (DOOM_FLAT_WIDTH + 2 * HOLLOW_BORDER - 1);
+		block.y1 = iy1;
+		block.y0 =
+		    block.y1 - (DOOM_FLAT_HEIGHT + 2 * HOLLOW_BORDER - 1);
+		block.name = sec->floort;
+		display_flat_depressed(&block);
+
+		// Display the ceiling texture above the floor texture
+		block.y1 = block.y0 - (WIDE_VSPACING + 1);
+		block.y0 =
+		    block.y1 - (DOOM_FLAT_HEIGHT + 2 * HOLLOW_BORDER - 1);
+		block.name = sec->ceilt;
+		display_flat_depressed(&block);
 	    }
-	  }
+
+	    // Show all EDGE extrafloors for this sector
+	    {
+		x0 += width;
+		const int columns2 = 16;
+		const int width2 = BOX_BORDER
+		    + WIDE_HSPACING
+		    + columns2 * FONTW
+		    + WIDE_HSPACING
+		    + HOLLOW_BORDER
+		    + DOOM_FLAT_WIDTH
+		    + HOLLOW_BORDER + WIDE_HSPACING + BOX_BORDER;
+		std::vector < Extraf > v;
+		get_extrafloors(v, sec->tag);
+		size_t e;
+		for (e = 0; e < v.size() && e + 1 < MAX_BOXES;
+		     e++, x0 += width2)
+		{
+		    const Extraf & i = v[e];
+		    obj_no_t dsecno = i.sector;
+		    bool thick = (*i.tex != '\0');
+		    const struct Sector *dsec = Sectors + dsecno;
+		    x1 = x0 + width2 - 1;
+		    y1 = y0 + height - 1;
+		    ix0 = x0 + BOX_BORDER + WIDE_HSPACING;
+		    iy0 = y0 + BOX_BORDER + WIDE_VSPACING;
+		    ix1 = x1 - BOX_BORDER - WIDE_HSPACING;
+		    iy1 = y1 - BOX_BORDER - WIDE_VSPACING;
+		    if (box_disp[e + 1])	// FIXME
+		    {
+			push_colour(WINBG);
+			DrawScreenBox(ix0, iy0, ix0 + columns2 * FONTW - 1,
+				      iy1);
+			pop_colour();
+		    }
+		    else
+		    {
+			DrawScreenBox3D(x0, y0, x1, y1);
+			box_disp[e + 1] = true;
+		    }
+		    if (!is_sector(dsecno))	// Can't happen
+			continue;
+		    set_colour(WINTITLE);
+		    if (thick)
+			DrawScreenText(ix0, iy0, "Thick #%d", dsecno);
+		    else
+			DrawScreenText(ix0, iy0, "Thin #%d", dsecno);
+		    set_colour(WINFG);
+		    if (thick)
+		    {
+			DrawScreenText(-1, iy0 + (int) (1.5 * FONTH),
+				       "\1Bottom:\2 %d", dsec->floorh);
+			DrawScreenText(-1, -1, "\1Top:\2    %d", dsec->ceilh);
+			DrawScreenText(-1, -1, "\1Thick:\2  %d",
+				       dsec->ceilh - dsec->floorh);
+			DrawScreenText(-1, -1, "\1Bottom:\2 %.*s",
+				       WAD_FLAT_NAME, dsec->floort);
+			DrawScreenText(-1, -1, "\1Top:\2    %.*s",
+				       WAD_FLAT_NAME, dsec->ceilt);
+		    }
+		    else
+		    {
+			DrawScreenText(-1, iy0 + (int) (1.5 * FONTH),
+				       "\1Height:\2 %d", dsec->floorh);
+			DrawScreenText(-1, -1, "\1Flat:\2   %.*s",
+				       WAD_FLAT_NAME, dsec->floort);
+		    }
+		    DrawScreenText(-1, -1, "\1Shadow:\2 %d", dsec->light);
+		    DrawScreenText(-1, -1, "\1Type:\2   %d", dsec->special);
+		    if (thick)
+			DrawScreenText(-1, -1, "\1Side:\2   %.*s",
+				       WAD_TEX_NAME, i.tex);
+		    {
+			hookfunc_comm_t block;
+
+			// Display the top texture in the bottom right corner
+			block.x1 = ix1;
+			block.x0 =
+			    block.x1 - (DOOM_FLAT_WIDTH + 2 * HOLLOW_BORDER -
+					1);
+			block.y1 = iy1;
+			block.y0 =
+			    block.y1 - (DOOM_FLAT_HEIGHT + 2 * HOLLOW_BORDER -
+					1);
+			block.name = dsec->floort;
+			display_flat_depressed(&block);
+
+			// Display the bottom texture above the floor texture
+			block.y1 = block.y0 - (WIDE_VSPACING + 1);
+			block.y0 =
+			    block.y1 - (DOOM_FLAT_HEIGHT + 2 * HOLLOW_BORDER -
+					1);
+			if (thick)
+			{
+			    block.name = dsec->ceilt;
+			    display_flat_depressed(&block);
+			}
+			else
+			{
+			    push_colour(WINBG);
+			    DrawScreenBoxwh(block.x0, block.y0,
+					    DOOM_FLAT_WIDTH +
+					    2 * HOLLOW_BORDER,
+					    DOOM_FLAT_HEIGHT +
+					    2 * HOLLOW_BORDER);
+			    pop_colour();
+			}
+		    }
+		}
+		// Clear out remaining boxes
+		for (; e + 1 < MAX_BOXES && box_disp[e + 1];
+		     e++, x0 += width2)
+		{
+		    x1 = x0 + width2 - 1;
+		    y1 = y0 + height - 1;
+		    ix0 = x0 + BOX_BORDER + WIDE_HSPACING;
+		    iy0 = y0 + BOX_BORDER + WIDE_VSPACING;
+		    ix1 = x1 - BOX_BORDER - WIDE_HSPACING;
+		    iy1 = y1 - BOX_BORDER - WIDE_VSPACING;
+		    push_colour(WINBG);
+		    DrawScreenBox(ix0, iy0, ix1, iy1);
+		    pop_colour();
+		}
+	    }
+	    break;
 	}
-	// Clear out remaining boxes
-	for (; e + 1 < MAX_BOXES && box_disp[e + 1]; e++, x0 += width2)
+    }
+
+    if (obj_type == OBJ_SECTORS)
+    {
+	if (obj_no != prev_sector)
+	    prev_sector = obj_no;
+	if (obj_no >= 0)
 	{
-	  x1 = x0 + width2 - 1;
-	  y1 = y0 + height - 1;
-	  ix0 = x0 + BOX_BORDER + WIDE_HSPACING;
-	  iy0 = y0 + BOX_BORDER + WIDE_VSPACING;
-	  ix1 = x1 - BOX_BORDER - WIDE_HSPACING;
-	  iy1 = y1 - BOX_BORDER - WIDE_VSPACING;
-	  push_colour (WINBG);
-	  DrawScreenBox (ix0, iy0, ix1, iy1);
-	  pop_colour ();
+	    prev_floorh = Sectors[obj_no].floorh;
+	    prev_ceilh = Sectors[obj_no].ceilh;
 	}
-      }
-      break;
     }
-  }
-
-  if (obj_type == OBJ_SECTORS)
-  {
-    if (obj_no != prev_sector)
-      prev_sector = obj_no;
-    if (obj_no >= 0)
-    {
-      prev_floorh = Sectors[obj_no].floorh;
-      prev_ceilh  = Sectors[obj_no].ceilh;
-    }
-  }
-  box_disp[0] = true;
-  obj_no_disp = obj_no;
-  obj_type_disp = obj_type;
+    box_disp[0] = true;
+    obj_no_disp = obj_no;
+    obj_type_disp = obj_type;
 }
 
 
@@ -756,32 +793,28 @@
  *	- <height> is the to the floor height of the dummy
  *	  sector.
  */
-static void get_extrafloors (std::vector<Extraf>& v, wad_tag_t tag)
+static void get_extrafloors(std::vector < Extraf > &v, wad_tag_t tag)
 {
-  v.clear ();
-  for (obj_no_t l = 0; l < NumLineDefs; l++)
-  {
-    if (LineDefs[l].tag == tag
-      && LineDefs[l].type >= 400 && LineDefs[l].type <= 407)  // FIXME
+    v.clear();
+    for (obj_no_t l = 0; l < NumLineDefs; l++)
     {
-      obj_no_t sd = LineDefs[l].sidedef1;
-      if (! is_sidedef (sd) || ! is_sector (SideDefs[sd].sector))  // Paranoia
-	continue;
-      wad_tex_name_t tex;
-      if (LineDefs[l].type == 400)
-	memcpy (tex, SideDefs[sd].tex3, sizeof tex);
-      else if (LineDefs[l].type == 401)		// side_upper
-	memcpy (tex, SideDefs[sd].tex1, sizeof tex);
-      else if (LineDefs[l].type == 402)		// side_lower
-	memcpy (tex, SideDefs[sd].tex2, sizeof tex);
-      else
-	memset (tex, '\0', sizeof tex);
-      v.push_back (Extraf (SideDefs[sd].sector,
-			   tex,
-			   Sectors[SideDefs[sd].sector].floorh));
+	if (LineDefs[l].tag == tag && LineDefs[l].type >= 400 && LineDefs[l].type <= 407)	// FIXME
+	{
+	    obj_no_t sd = LineDefs[l].sidedef1;
+	    if (!is_sidedef(sd) || !is_sector(SideDefs[sd].sector))	// Paranoia
+		continue;
+	    wad_tex_name_t tex;
+	    if (LineDefs[l].type == 400)
+		memcpy(tex, SideDefs[sd].tex3, sizeof tex);
+	    else if (LineDefs[l].type == 401)	// side_upper
+		memcpy(tex, SideDefs[sd].tex1, sizeof tex);
+	    else if (LineDefs[l].type == 402)	// side_lower
+		memcpy(tex, SideDefs[sd].tex2, sizeof tex);
+	    else
+		memset(tex, '\0', sizeof tex);
+	    v.push_back(Extraf(SideDefs[sd].sector,
+			       tex, Sectors[SideDefs[sd].sector].floorh));
+	}
     }
-  }
-  sort (v.begin (), v.end ());
+    sort(v.begin(), v.end());
 }
-
-
--- a/src/objinfo.h	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/objinfo.h	Sat Sep 24 14:16:04 2011 +0300
@@ -30,51 +30,58 @@
 #include "edwidget.h"
 
 
-class objinfo_c : public edwidget_c
-   {
-   public :
-      objinfo_c ();
-      void set (int obj_type, int obj_no)
-      {
-        this->obj_no   = obj_no;
+class objinfo_c:public edwidget_c
+{
+    public: objinfo_c();
+    void set(int obj_type, int obj_no)
+    {
+	this->obj_no = obj_no;
 	this->obj_type = obj_type;
-      }
+    }
 
-      void set_y1 (int y1)
-	 { out_y1 = y1; }
+    void set_y1(int y1)
+    {
+	out_y1 = y1;
+    }
 
-      /* Methods declared in edwidget_c */
-      void unset ()
-	 { obj_no = OBJ_NO_NONE; }
+    /* Methods declared in edwidget_c */
+    void unset()
+    {
+	obj_no = OBJ_NO_NONE;
+    }
 
-      void draw ();
+    void draw();
 
-      void undraw ()
-         { }  // Sorry, I don't know how to undraw myself
+    void undraw()
+    {
+    }				// Sorry, I don't know how to undraw myself
 
-      int can_undraw ()
-         { return 0; }  // I don't have the ability to undraw myself
-
-      int need_to_clear ()
-	 { return is_obj (obj_no_disp) && ! is_obj (obj_no); }
+    int can_undraw()
+    {
+	return 0;
+    }				// I don't have the ability to undraw myself
 
-      void clear ()
-      {
-	for (size_t n = 0; n < MAX_BOXES; n++)
-	  box_disp[n] = false;
-	obj_no_disp = OBJ_NO_NONE;
-      }
+    int need_to_clear()
+    {
+	return is_obj(obj_no_disp) && !is_obj(obj_no);
+    }
 
-   private :
-      static const size_t MAX_BOXES = 10;
-      bool box_disp[MAX_BOXES];	// Is the box already drawn ?
-      int obj_no;        // The no. of the object we should display info about
-      int obj_type;      // The type of the object we should display info about
-      int obj_no_disp;	 // The no. and type of the object for which info
-      int obj_type_disp; // is really displayed.
-      int prev_sector;   // No. of the last sector for which info was displayed
-      int prev_floorh;   // Its floor height.
-      int prev_ceilh;    // Its ceiling height.
-      int out_y1;        // The bottom outer edge of the info window.
-   };
+    void clear()
+    {
+	for (size_t n = 0; n < MAX_BOXES; n++)
+	    box_disp[n] = false;
+	obj_no_disp = OBJ_NO_NONE;
+    }
 
+  private:
+    static const size_t MAX_BOXES = 10;
+    bool box_disp[MAX_BOXES];	// Is the box already drawn ?
+    int obj_no;			// The no. of the object we should display info about
+    int obj_type;		// The type of the object we should display info about
+    int obj_no_disp;		// The no. and type of the object for which info
+    int obj_type_disp;		// is really displayed.
+    int prev_sector;		// No. of the last sector for which info was displayed
+    int prev_floorh;		// Its floor height.
+    int prev_ceilh;		// Its ceiling height.
+    int out_y1;			// The bottom outer edge of the info window.
+};
--- a/src/oldmenus.cc	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/oldmenus.cc	Sat Sep 24 14:16:04 2011 +0300
@@ -41,7 +41,7 @@
 #include "oldmenus.h"
 
 
-static int loop (Menu *menu, int x, int y, int item_no);
+static int loop(Menu * menu, int x, int y, int item_no);
 
 
 /*
@@ -52,15 +52,15 @@
  *
  *	Return the same thing as Menu::process_event().
  */
-int vDisplayMenu (int x0, int y0, const char *title, ...)
+int vDisplayMenu(int x0, int y0, const char *title, ...)
 {
-  va_list args;
+    va_list args;
 
-  va_start (args, title);
-  Menu menu (title, args);
-  va_end (args);
-  int r = loop (&menu, x0, y0, 0);
-  return r + 1;
+    va_start(args, title);
+    Menu menu(title, args);
+    va_end(args);
+    int r = loop(&menu, x0, y0, 0);
+    return r + 1;
 }
 
 
@@ -76,19 +76,17 @@
  *
  *	This function is deprecated.
  */
-int DisplayMenuList (
-  int		x0,
-  int		y0,
-  const char	*menutitle,
-  al_llist_t	*list,
-  const char	*(*getstr)(void *),
-  int		*item_no)
+int DisplayMenuList(int x0,
+		    int y0,
+		    const char *menutitle,
+		    al_llist_t * list,
+		    const char *(*getstr) (void *), int *item_no)
 {
-  Menu menu (menutitle, list, getstr);
-  int r = loop (&menu, x0, y0, item_no ? *item_no : 0);
-  if (item_no && r >= 0)
-    *item_no = r;
-  return r;
+    Menu menu(menutitle, list, getstr);
+    int r = loop(&menu, x0, y0, item_no ? *item_no : 0);
+    if (item_no && r >= 0)
+	*item_no = r;
+    return r;
 }
 
 
@@ -102,18 +100,15 @@
  *
  *	This function is deprecated.
  */
-int DisplayMenuList (
-  int		x0,
-  int		y0,
-  const char	*menutitle,
-  Menu_data&    menudata,
-  int		*item_no)
+int DisplayMenuList(int x0,
+		    int y0,
+		    const char *menutitle, Menu_data & menudata, int *item_no)
 {
-  Menu menu (menutitle, menudata);
-  int r = loop (&menu, x0, y0, item_no ? *item_no : 0);
-  if (item_no && r >= 0)
-    *item_no = r;
-  return r;
+    Menu menu(menutitle, menudata);
+    int r = loop(&menu, x0, y0, item_no ? *item_no : 0);
+    if (item_no && r >= 0)
+	*item_no = r;
+    return r;
 }
 
 
@@ -127,41 +122,40 @@
  *	hack, provided as a stopgap until the widget stack is
  *	implemented and the code uses it. 
  */
-static int loop (Menu *menu, int x, int y, int item_no)
+static int loop(Menu * menu, int x, int y, int item_no)
 {
-  menu->set_popup         (true);
-  menu->set_force_numbers (true);
-  menu->set_coords        (x, y);
-  menu->set_visible       (true);
-  menu->set_item_no       (item_no);
-  for (;;)
-  {
-    menu->draw ();
-    if (has_event ())
+    menu->set_popup(true);
+    menu->set_force_numbers(true);
+    menu->set_coords(x, y);
+    menu->set_visible(true);
+    menu->set_item_no(item_no);
+    for (;;)
     {
-      is.key = get_event ();
-      // If we had called get_input_status(), XNextEvent()
-      // would have been called and we wouldn't have to do that.
-      XFlush (dpy);
+	menu->draw();
+	if (has_event())
+	{
+	    is.key = get_event();
+	    // If we had called get_input_status(), XNextEvent()
+	    // would have been called and we wouldn't have to do that.
+	    XFlush(dpy);
+	}
+	else
+	    get_input_status();
+	if (is.key == YE_EXPOSE)
+	    menu->clear();	// Force menu to redraw itself from scratch
+	else if (is.key == YE_BUTL_PRESS
+		 && ((int) is.x < menu->get_x0()
+		     || (int) is.x > menu->get_x1()
+		     || (int) is.y < menu->get_y0()
+		     || (int) is.y > menu->get_y1()))
+	    return -1;
+	else
+	{
+	    int r = menu->process_event(&is);
+	    if (r == MEN_CANCEL)
+		return -1;
+	    else if (r >= 0)
+		return r;
+	}
     }
-    else
-      get_input_status ();
-    if (is.key == YE_EXPOSE)
-      menu->clear ();  // Force menu to redraw itself from scratch
-    else if (is.key == YE_BUTL_PRESS
-      && ((int) is.x < menu->get_x0 ()
-	 || (int) is.x > menu->get_x1 ()
-	 || (int) is.y < menu->get_y0 ()
-	 || (int) is.y > menu->get_y1 ()))
-      return -1;
-    else
-    {
-      int r = menu->process_event (&is);
-      if (r == MEN_CANCEL)
-	 return -1;
-      else if (r >= 0)
-	 return r;
-    }
-  }
 }
-
--- a/src/oldmenus.h	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/oldmenus.h	Sat Sep 24 14:16:04 2011 +0300
@@ -4,29 +4,25 @@
  */
 
 
-#ifndef YH_OLDMENUS  /* DO NOT INSERT ANYTHING BEFORE THIS LINE */
+#ifndef YH_OLDMENUS		/* DO NOT INSERT ANYTHING BEFORE THIS LINE */
 #define YH_OLDMENUS
 
 
 class Menu_data;
 
 
-int vDisplayMenu (int, int, const char *, ...);
+int vDisplayMenu(int, int, const char *, ...);
 
-int DisplayMenuList (
-   int		x0,
-   int		y0,
-   const char	*title,
-   al_llist_t	*list,
-   const char	*(*getstr)(void *),
-   int		*item_no);
+int DisplayMenuList(int x0,
+		    int y0,
+		    const char *title,
+		    al_llist_t * list,
+		    const char *(*getstr) (void *), int *item_no);
 
-int DisplayMenuList (
-  int		x0,
-  int		y0,
-  const char	*menutitle,
-  Menu_data&    menudata,
-  int		*item_no);
+int DisplayMenuList(int x0,
+		    int y0,
+		    const char *menutitle,
+		    Menu_data & menudata, int *item_no);
 
 
-#endif  /* DO NOT ADD ANYTHING AFTER THIS LINE */
+#endif /* DO NOT ADD ANYTHING AFTER THIS LINE */
--- a/src/palview.cc	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/palview.cc	Sat Sep 24 14:16:04 2011 +0300
@@ -46,388 +46,389 @@
  */
 
 // One COLORMAP entry. Wrapped in struct to avoid array<->pointer problems
-typedef struct { u8 c[DOOM_COLOURS]; } colormap_entry_t;
+typedef struct
+{
+    u8 c[DOOM_COLOURS];
+} colormap_entry_t;
 
-void Palette_viewer::run ()
+void Palette_viewer::run()
 {
-int       lines    = (ncolours + columns - 1) / columns;
-const int pwidth   = columns * (pixels + 1);
-const int pheight  = lines * (pixels + 1);
-int       width    = 2 * BOX_BORDER + 2 * WIDE_HSPACING + pwidth;
-int       height   = 2 * BOX_BORDER + 3 * WIDE_VSPACING + pheight + 7 * FONTH;
-int       x0       = (ScrMaxX - width) / 2;
-int       y0       = (ScrMaxY - height) / 2;
-int       nmaps    = 0;  // Number of entries in the COLORMAP lump
-colormap_entry_t **colormap = 0;
-rgb_c    *playpal  = 0;
+    int lines = (ncolours + columns - 1) / columns;
+    const int pwidth = columns * (pixels + 1);
+    const int pheight = lines * (pixels + 1);
+    int width = 2 * BOX_BORDER + 2 * WIDE_HSPACING + pwidth;
+    int height = 2 * BOX_BORDER + 3 * WIDE_VSPACING + pheight + 7 * FONTH;
+    int x0 = (ScrMaxX - width) / 2;
+    int y0 = (ScrMaxY - height) / 2;
+    int nmaps = 0;		// Number of entries in the COLORMAP lump
+    colormap_entry_t **colormap = 0;
+    rgb_c *playpal = 0;
 
 // Load the PLAYPAL lump
-do
-{
-  playpal = new rgb_c[DOOM_COLOURS];
-  for (size_t n = 0; n < DOOM_COLOURS; n++)
-    playpal[n].set (0, 0, 0);
-  const char *lump_name = "PLAYPAL";
-  MDirPtr dir = FindMasterDir (MasterDir, lump_name);
-  if (dir == NULL)
-  {
-    warn ("%s: lump not found\n", lump_name);
-    break;
-  }
-  const Wad_file *wf = dir->wadfile;
-  if (dir->dir.size % (3 * DOOM_COLOURS) != 0)
-  {
-    warn ("%s has weird size (%ld, not mult of %d), ignoring tail\n",
-      lump_name, (long) dir->dir.size, (int) (DOOM_COLOURS * 3));
-  }
-  wf->seek (dir->dir.start);
-  if (wf->error ())
-  {
-    warn ("%s: seek error\n", lump_name);
-    break;
-  }
-  playpal = new rgb_c[DOOM_COLOURS];
-  for (size_t n = 0; n < DOOM_COLOURS; n++)
-  {
-    char buf[3];
-    wf->read_bytes (buf, sizeof buf);
-    playpal[n].set (buf[0], buf[1], buf[2]);
-  }
-  if (wf->error ())
-    warn ("%s: read error\n", lump_name);
-}
-while (0);
+    do
+    {
+	playpal = new rgb_c[DOOM_COLOURS];
+	for (size_t n = 0; n < DOOM_COLOURS; n++)
+	    playpal[n].set(0, 0, 0);
+	const char *lump_name = "PLAYPAL";
+	MDirPtr dir = FindMasterDir(MasterDir, lump_name);
+	if (dir == NULL)
+	{
+	    warn("%s: lump not found\n", lump_name);
+	    break;
+	}
+	const Wad_file *wf = dir->wadfile;
+	if (dir->dir.size % (3 * DOOM_COLOURS) != 0)
+	{
+	    warn("%s has weird size (%ld, not mult of %d), ignoring tail\n",
+		 lump_name, (long) dir->dir.size, (int) (DOOM_COLOURS * 3));
+	}
+	wf->seek(dir->dir.start);
+	if (wf->error())
+	{
+	    warn("%s: seek error\n", lump_name);
+	    break;
+	}
+	playpal = new rgb_c[DOOM_COLOURS];
+	for (size_t n = 0; n < DOOM_COLOURS; n++)
+	{
+	    char buf[3];
+	    wf->read_bytes(buf, sizeof buf);
+	    playpal[n].set(buf[0], buf[1], buf[2]);
+	}
+	if (wf->error())
+	    warn("%s: read error\n", lump_name);
+    }
+    while (0);
 
 // Load the COLORMAP lump
-do
-{
-  const char *lump_name = "COLORMAP";
-  MDirPtr dir = FindMasterDir (MasterDir, lump_name);
-  if (dir == NULL)
-  {
-    warn ("%s: lump not found\n", lump_name);
-    break;
-  }
-  const Wad_file *wf = dir->wadfile;
-  nmaps = dir->dir.size / DOOM_COLOURS;
-  if ((long) DOOM_COLOURS * nmaps != dir->dir.size)
-  {
-    warn ("%s: has weird size (%ld, not mult of %d), ignoring tail\n",
-      lump_name, (long) dir->dir.size, (int) DOOM_COLOURS);
-  }
-  if (nmaps > 200)
-  {
-    warn ("%s has too many (%d) entries, keeping only 200 first\n",
-	lump_name, nmaps);
-    nmaps = 200;
-  }
-  wf->seek (dir->dir.start);
-  if (wf->error ())
-  {
-    warn ("%s: seek error\n", lump_name);
-    break;
-  }
-  colormap = new colormap_entry_t *[nmaps];
-  for (int n = 0; n < nmaps; n++)
-  {
-    colormap[n] = new colormap_entry_t;
-    wf->read_bytes (colormap[n]->c, sizeof colormap[n]->c);
-  }
-  if (wf->error ())
-    warn ("%s: read error\n", lump_name);
-}
-while (0);
+    do
+    {
+	const char *lump_name = "COLORMAP";
+	MDirPtr dir = FindMasterDir(MasterDir, lump_name);
+	if (dir == NULL)
+	{
+	    warn("%s: lump not found\n", lump_name);
+	    break;
+	}
+	const Wad_file *wf = dir->wadfile;
+	nmaps = dir->dir.size / DOOM_COLOURS;
+	if ((long) DOOM_COLOURS * nmaps != dir->dir.size)
+	{
+	    warn("%s: has weird size (%ld, not mult of %d), ignoring tail\n",
+		 lump_name, (long) dir->dir.size, (int) DOOM_COLOURS);
+	}
+	if (nmaps > 200)
+	{
+	    warn("%s has too many (%d) entries, keeping only 200 first\n",
+		 lump_name, nmaps);
+	    nmaps = 200;
+	}
+	wf->seek(dir->dir.start);
+	if (wf->error())
+	{
+	    warn("%s: seek error\n", lump_name);
+	    break;
+	}
+	colormap = new colormap_entry_t *[nmaps];
+	for (int n = 0; n < nmaps; n++)
+	{
+	    colormap[n] = new colormap_entry_t;
+	    wf->read_bytes(colormap[n]->c, sizeof colormap[n]->c);
+	}
+	if (wf->error())
+	    warn("%s: read error\n", lump_name);
+    }
+    while (0);
 
 // On to the real business
-ix0 = x0 + BOX_BORDER + WIDE_HSPACING;
-iy0 = y0 + BOX_BORDER + WIDE_VSPACING;
-int tx0 = ix0;					// Top left corner of text
-int ty0 = y0 + BOX_BORDER + 2 * WIDE_VSPACING + pheight;
-push_colour (0);				// Save current colour
+    ix0 = x0 + BOX_BORDER + WIDE_HSPACING;
+    iy0 = y0 + BOX_BORDER + WIDE_VSPACING;
+    int tx0 = ix0;		// Top left corner of text
+    int ty0 = y0 + BOX_BORDER + 2 * WIDE_VSPACING + pheight;
+    push_colour(0);		// Save current colour
 #define DECIDX(i,n) do { i = (i - n + ncolours) % ncolours; } while (0)
 #define INCIDX(i,n) do { i = (i + n           ) % ncolours; } while (0)
-int           mapno         = 0;
-bool          mapping       = true;
-int           is_drawn      = 0;
-const int     YID_WINDOW    = 0x01;
-const int     YID_CURSOR    = 0x02;
-const int     YID_PALETTE   = 0x04;
-const int     YID_TEXT      = 0x08;
-int           cursor_phase  = 0;
-int           display_phase = 0;
-unsigned long cursor_time   = 0;
-i   = 0;
-ofs = 0;
+    int mapno = 0;
+    bool mapping = true;
+    int is_drawn = 0;
+    const int YID_WINDOW = 0x01;
+    const int YID_CURSOR = 0x02;
+    const int YID_PALETTE = 0x04;
+    const int YID_TEXT = 0x08;
+    int cursor_phase = 0;
+    int display_phase = 0;
+    unsigned long cursor_time = 0;
+    i = 0;
+    ofs = 0;
 
-for (;;)
-{
-  int mi = colormap[mapno]->c[i];	// Mapped index
-  int ei = mapping ? mi : i;		// Effective index
-  int mapped_to = 0;			// N. distinct colours that map to i
-  for (int n = 0; n < ncolours; n++)
-    for (int m = 0; m < nmaps; m++)
-      if (colormap[m]->c[n] == i)
-      {
-	mapped_to++;
-	break;        // Don't count the same mapper twice
-      }
-  int maps_to = 0;			// N. distinct colours that i maps to
-  {
-    bitvec_c mappee (ncolours);
-    for (int m = 0; m < nmaps; m++)
-      mappee.set (colormap[m]->c[i]);
-    for (int n = 0; n < ncolours; n++)
-      if (mappee.get (n))
-	maps_to++;
-  }
-
-  // Draw the window
-  if (! (is_drawn & YID_WINDOW))
-  {
-    DrawScreenBox3D (x0, y0, x0 + width - 1, y0 + height - 1);
-    is_drawn = YID_WINDOW;  // Redraw everything else
-  }
-
-  // Draw the cursor (frame around the current cell)
-  {
-    const int cycle = 800;  // 800 ms
-    unsigned long current_time = y_milliseconds ();
-    unsigned long elapsed_time = current_time - cursor_time;
-    cursor_time = current_time;
-#if 0
-    cursor_time += elapsed_time - elapsed_time % cycle;  // Normalize
-    elapsed_time = current_time - cursor_time;
-#endif
-    cursor_phase = (cursor_phase + elapsed_time) % cycle;
-    if ((cursor_phase >= cycle / 2) != (display_phase >= cycle / 2))
-      is_drawn &= ~YID_CURSOR;
-    if (! (is_drawn & YID_CURSOR))
+    for (;;)
     {
-      draw_cursor (WINFG, cursor_phase >= cycle / 2);
-      display_phase = cursor_phase;
-      is_drawn |= YID_CURSOR;
-    }
-  }
+	int mi = colormap[mapno]->c[i];	// Mapped index
+	int ei = mapping ? mi : i;	// Effective index
+	int mapped_to = 0;	// N. distinct colours that map to i
+	for (int n = 0; n < ncolours; n++)
+	    for (int m = 0; m < nmaps; m++)
+		if (colormap[m]->c[n] == i)
+		{
+		    mapped_to++;
+		    break;	// Don't count the same mapper twice
+		}
+	int maps_to = 0;	// N. distinct colours that i maps to
+	{
+	    bitvec_c mappee(ncolours);
+	    for (int m = 0; m < nmaps; m++)
+		mappee.set(colormap[m]->c[i]);
+	    for (int n = 0; n < ncolours; n++)
+		if (mappee.get(n))
+		    maps_to++;
+	}
 
-  // Draw a (pixels x pixels) square for each colour
-  if (! (is_drawn & YID_PALETTE))
-  {
-    int x = 0;  // Initialized only to prevent GCC from warning
-    int y = 0;  // Initialized only to prevent GCC from warning
-    for (int n = 0; n < ncolours; n++)
-    {
-      if (n % columns == 0)
-      {
-	x = ix0;
-	if (n == 0)
-	  y = iy0;
-	else
-	  y += pixels + 1;
-      }
-      else
-	x += pixels + 1;
+	// Draw the window
+	if (!(is_drawn & YID_WINDOW))
+	{
+	    DrawScreenBox3D(x0, y0, x0 + width - 1, y0 + height - 1);
+	    is_drawn = YID_WINDOW;	// Redraw everything else
+	}
+
+	// Draw the cursor (frame around the current cell)
+	{
+	    const int cycle = 800;	// 800 ms
+	    unsigned long current_time = y_milliseconds();
+	    unsigned long elapsed_time = current_time - cursor_time;
+	    cursor_time = current_time;
+#if 0
+	    cursor_time += elapsed_time - elapsed_time % cycle;	// Normalize
+	    elapsed_time = current_time - cursor_time;
+#endif
+	    cursor_phase = (cursor_phase + elapsed_time) % cycle;
+	    if ((cursor_phase >= cycle / 2) != (display_phase >= cycle / 2))
+		is_drawn &= ~YID_CURSOR;
+	    if (!(is_drawn & YID_CURSOR))
+	    {
+		draw_cursor(WINFG, cursor_phase >= cycle / 2);
+		display_phase = cursor_phase;
+		is_drawn |= YID_CURSOR;
+	    }
+	}
 
-      if (game_colour == 0)  // If PLAYPAL not found
-	set_pcolour (0);
-      else
-      {
-	if (mapping)
-	  set_pcolour (game_colour[colormap[mapno]->c[(n + ofs) % ncolours]]);
-	else
-	  set_pcolour (game_colour[(n + ofs) % ncolours]);
-      }
-      DrawScreenBoxwh (x, y, pixels, pixels);
-    }
-    is_drawn |= YID_PALETTE;
-    set_colour (WINFG_DIM);  // Just to force the next set_colour() to do sth
-  }
+	// Draw a (pixels x pixels) square for each colour
+	if (!(is_drawn & YID_PALETTE))
+	{
+	    int x = 0;		// Initialized only to prevent GCC from warning
+	    int y = 0;		// Initialized only to prevent GCC from warning
+	    for (int n = 0; n < ncolours; n++)
+	    {
+		if (n % columns == 0)
+		{
+		    x = ix0;
+		    if (n == 0)
+			y = iy0;
+		    else
+			y += pixels + 1;
+		}
+		else
+		    x += pixels + 1;
 
-  // Draw the "caption"
-  if (! (is_drawn & YID_TEXT))
-  {
-    set_colour (WINBG);
-    DrawScreenBoxwh (tx0, ty0, pwidth, 7 * FONTH);
-    set_colour (WINFG);
-    DrawScreenText (tx0, ty0, "Index        %3d", i);
-    push_colour (mapping ? WINFG : WINFG_DIM);
-    DrawScreenText (tx0, -1,  "Mapped index %3d", mi);
-    pop_colour ();
-    DrawScreenText (tx0, -1,  "R            %3d", playpal[ei].r);
-    DrawScreenText (tx0, -1,  "G            %3d", playpal[ei].g);
-    DrawScreenText (tx0, -1,  "B            %3d", playpal[ei].b);
-    DrawScreenText (tx0, -1,  "Mapped to by %3d", mapped_to);
-    DrawScreenText (tx0, -1,  "Maps to      %3d", maps_to);
-    push_colour (mapping ? WINFG : WINFG_DIM);
-    DrawScreenText (tx0 + 18 * FONTW, ty0, "Colormap %3d", mapno);
-    pop_colour ();
-    is_drawn |= YID_TEXT;
-  }
+		if (game_colour == 0)	// If PLAYPAL not found
+		    set_pcolour(0);
+		else
+		{
+		    if (mapping)
+			set_pcolour(game_colour
+				    [colormap[mapno]->
+				     c[(n + ofs) % ncolours]]);
+		    else
+			set_pcolour(game_colour[(n + ofs) % ncolours]);
+		}
+		DrawScreenBoxwh(x, y, pixels, pixels);
+	    }
+	    is_drawn |= YID_PALETTE;
+	    set_colour(WINFG_DIM);	// Just to force the next set_colour() to do sth
+	}
+
+	// Draw the "caption"
+	if (!(is_drawn & YID_TEXT))
+	{
+	    set_colour(WINBG);
+	    DrawScreenBoxwh(tx0, ty0, pwidth, 7 * FONTH);
+	    set_colour(WINFG);
+	    DrawScreenText(tx0, ty0, "Index        %3d", i);
+	    push_colour(mapping ? WINFG : WINFG_DIM);
+	    DrawScreenText(tx0, -1, "Mapped index %3d", mi);
+	    pop_colour();
+	    DrawScreenText(tx0, -1, "R            %3d", playpal[ei].r);
+	    DrawScreenText(tx0, -1, "G            %3d", playpal[ei].g);
+	    DrawScreenText(tx0, -1, "B            %3d", playpal[ei].b);
+	    DrawScreenText(tx0, -1, "Mapped to by %3d", mapped_to);
+	    DrawScreenText(tx0, -1, "Maps to      %3d", maps_to);
+	    push_colour(mapping ? WINFG : WINFG_DIM);
+	    DrawScreenText(tx0 + 18 * FONTW, ty0, "Colormap %3d", mapno);
+	    pop_colour();
+	    is_drawn |= YID_TEXT;
+	}
 
-  // Process any events
-  get_input_status ();
-  if (is.key == YK_PU)			// [Pgup] previous colormap
-  {
-    mapno--;
-    if (mapno < 0)
-      mapno = nmaps - 1;
-    is_drawn &= ~(YID_PALETTE | YID_TEXT);
-  }
-  else if (is.key == YK_PD)		// [Pgdn] next colormap
-  {
-    mapno++;
-    if (mapno >= nmaps)
-      mapno = 0;
-    is_drawn &= ~(YID_PALETTE | YID_TEXT);
-  }
-  else if (is.key == YK_LEFT)		// [Left] previous palette entry
-  {
-    draw_cursor (WINBG, false);
-    DECIDX (i, 1);
-    is_drawn &= ~(YID_PALETTE | YID_TEXT | YID_CURSOR);
-    cursor_phase = 0;
-  }
-  else if (is.key == YK_RIGHT)		// [Right] next palette entry
-  {
-    draw_cursor (WINBG, false);
-    INCIDX (i, 1);
-    is_drawn &= ~(YID_TEXT | YID_CURSOR);
-    cursor_phase = 0;
-  }
-  else if (is.key == YK_UP)		// [Up] previous palette row
-  {
-    draw_cursor (WINBG, false);
-    DECIDX (i, columns);
-    is_drawn &= ~(YID_TEXT | YID_CURSOR);
-    cursor_phase = 0;
-  }
-  else if (is.key == YK_DOWN)		// [Down] next palette row
-  {
-    draw_cursor (WINBG, false);
-    INCIDX (i, columns);
-    is_drawn &= ~(YID_TEXT | YID_CURSOR);
-    cursor_phase = 0;
-  }
-  else if (is.key == YK_END		// [End], [$]: end of current line
-      || is.key == '$')
-  {
-    draw_cursor (WINBG, false);
-    i += columns - i % columns - 1;
-    is_drawn &= ~(YID_TEXT | YID_CURSOR);
-    cursor_phase = 0;
-  }
-  else if (is.key == YK_HOME		// [Home], [0], [^]: start of cur. line
-      || is.key == '^'
-      || is.key == '0')
-  {
-    draw_cursor (WINBG, false);
-    i -= i % columns;
-    is_drawn &= ~(YID_TEXT | YID_CURSOR);
-    cursor_phase = 0;
-  }
-  else if (is.key == YK_RETURN)		// [Return]: beginning of next line
-  {
-    draw_cursor (WINBG, false);
-    i += columns - i % columns;
-    is_drawn &= ~(YID_TEXT | YID_CURSOR);
-    cursor_phase = 0;
-  }
-#if 0  /* Conflicts with "rotate" */
-  else if (is.key == '-')		// [-]: beginning of previous line
-  {
-    draw_cursor (WINBG, false);
-    i -= columns + i % columns;
-    is_drawn &= ~(YID_TEXT | YID_CURSOR);
-    cursor_phase = 0;
-  }
+	// Process any events
+	get_input_status();
+	if (is.key == YK_PU)	// [Pgup] previous colormap
+	{
+	    mapno--;
+	    if (mapno < 0)
+		mapno = nmaps - 1;
+	    is_drawn &= ~(YID_PALETTE | YID_TEXT);
+	}
+	else if (is.key == YK_PD)	// [Pgdn] next colormap
+	{
+	    mapno++;
+	    if (mapno >= nmaps)
+		mapno = 0;
+	    is_drawn &= ~(YID_PALETTE | YID_TEXT);
+	}
+	else if (is.key == YK_LEFT)	// [Left] previous palette entry
+	{
+	    draw_cursor(WINBG, false);
+	    DECIDX(i, 1);
+	    is_drawn &= ~(YID_PALETTE | YID_TEXT | YID_CURSOR);
+	    cursor_phase = 0;
+	}
+	else if (is.key == YK_RIGHT)	// [Right] next palette entry
+	{
+	    draw_cursor(WINBG, false);
+	    INCIDX(i, 1);
+	    is_drawn &= ~(YID_TEXT | YID_CURSOR);
+	    cursor_phase = 0;
+	}
+	else if (is.key == YK_UP)	// [Up] previous palette row
+	{
+	    draw_cursor(WINBG, false);
+	    DECIDX(i, columns);
+	    is_drawn &= ~(YID_TEXT | YID_CURSOR);
+	    cursor_phase = 0;
+	}
+	else if (is.key == YK_DOWN)	// [Down] next palette row
+	{
+	    draw_cursor(WINBG, false);
+	    INCIDX(i, columns);
+	    is_drawn &= ~(YID_TEXT | YID_CURSOR);
+	    cursor_phase = 0;
+	}
+	else if (is.key == YK_END	// [End], [$]: end of current line
+		 || is.key == '$')
+	{
+	    draw_cursor(WINBG, false);
+	    i += columns - i % columns - 1;
+	    is_drawn &= ~(YID_TEXT | YID_CURSOR);
+	    cursor_phase = 0;
+	}
+	else if (is.key == YK_HOME	// [Home], [0], [^]: start of cur. line
+		 || is.key == '^' || is.key == '0')
+	{
+	    draw_cursor(WINBG, false);
+	    i -= i % columns;
+	    is_drawn &= ~(YID_TEXT | YID_CURSOR);
+	    cursor_phase = 0;
+	}
+	else if (is.key == YK_RETURN)	// [Return]: beginning of next line
+	{
+	    draw_cursor(WINBG, false);
+	    i += columns - i % columns;
+	    is_drawn &= ~(YID_TEXT | YID_CURSOR);
+	    cursor_phase = 0;
+	}
+#if 0				/* Conflicts with "rotate" */
+	else if (is.key == '-')	// [-]: beginning of previous line
+	{
+	    draw_cursor(WINBG, false);
+	    i -= columns + i % columns;
+	    is_drawn &= ~(YID_TEXT | YID_CURSOR);
+	    cursor_phase = 0;
+	}
 #endif
-  else if (is.key == 'G' 		// [G], [L]: beginning of last line
-      || is.key == 'L')
-  {
-    draw_cursor (WINBG, false);
-    i = (lines  - 1) * columns;
-    is_drawn &= ~(YID_TEXT | YID_CURSOR);
-    cursor_phase = 0;
-  }
-  else if (is.key == 'H')		// [H] beginning of first line
-  {
-    draw_cursor (WINBG, false);
-    i = 0;
-    is_drawn &= ~(YID_TEXT | YID_CURSOR);
-    cursor_phase = 0;
-  }
-  else if (is.key == 'm')		// [m] toggle mapping
-  {
-    mapping = ! mapping;
-    is_drawn &= ~(YID_PALETTE | YID_TEXT);
-  }
-  else if (is.key == 'M')		// [M] beginning of middle line
-  {
-    draw_cursor (WINBG, false);
-    i = (lines / 2) * columns;
-    is_drawn &= ~(YID_TEXT | YID_CURSOR);
-    cursor_phase = 0;
-  }
-  else if (is.key == '+' || is.key == '=')  // [+] increment offset
-  {
-    INCIDX (ofs, 1);
-    INCIDX (i, 1);
-    is_drawn &= ~(YID_PALETTE | YID_TEXT);
-  }
-  else if (is.key == '-')		// [-] decrement offset
-  {
-    DECIDX (ofs, 1);
-    DECIDX (i, 1);
-    is_drawn &= ~(YID_PALETTE | YID_TEXT);
-  }
-  else if (is.key == YK_ESC)		// [Esc] quit
-  {
-    break;
-  }
-  else if (is.key == YE_EXPOSE)
-  {
-    is_drawn = 0;  // Redraw everything
-  }
-  else
-    ;
-}
+	else if (is.key == 'G'	// [G], [L]: beginning of last line
+		 || is.key == 'L')
+	{
+	    draw_cursor(WINBG, false);
+	    i = (lines - 1) * columns;
+	    is_drawn &= ~(YID_TEXT | YID_CURSOR);
+	    cursor_phase = 0;
+	}
+	else if (is.key == 'H')	// [H] beginning of first line
+	{
+	    draw_cursor(WINBG, false);
+	    i = 0;
+	    is_drawn &= ~(YID_TEXT | YID_CURSOR);
+	    cursor_phase = 0;
+	}
+	else if (is.key == 'm')	// [m] toggle mapping
+	{
+	    mapping = !mapping;
+	    is_drawn &= ~(YID_PALETTE | YID_TEXT);
+	}
+	else if (is.key == 'M')	// [M] beginning of middle line
+	{
+	    draw_cursor(WINBG, false);
+	    i = (lines / 2) * columns;
+	    is_drawn &= ~(YID_TEXT | YID_CURSOR);
+	    cursor_phase = 0;
+	}
+	else if (is.key == '+' || is.key == '=')	// [+] increment offset
+	{
+	    INCIDX(ofs, 1);
+	    INCIDX(i, 1);
+	    is_drawn &= ~(YID_PALETTE | YID_TEXT);
+	}
+	else if (is.key == '-')	// [-] decrement offset
+	{
+	    DECIDX(ofs, 1);
+	    DECIDX(i, 1);
+	    is_drawn &= ~(YID_PALETTE | YID_TEXT);
+	}
+	else if (is.key == YK_ESC)	// [Esc] quit
+	{
+	    break;
+	}
+	else if (is.key == YE_EXPOSE)
+	{
+	    is_drawn = 0;	// Redraw everything
+	}
+	else;
+    }
 
-pop_colour ();				// Restore current colour
-delete[] playpal;
-for (int n = 0; n < nmaps; n++)
-    delete colormap[n];
-delete[] colormap;
+    pop_colour();		// Restore current colour
+    delete[]playpal;
+    for (int n = 0; n < nmaps; n++)
+	delete colormap[n];
+    delete[]colormap;
 }
 
 
-void Palette_viewer::draw_cursor (int c, bool phase)
+void Palette_viewer::draw_cursor(int c, bool phase)
 {
-  const int a = (i + ncolours - ofs) % ncolours;
-  const int side = pixels + 2;
-  const int x0 = ix0 - 1 + (side - 1) * (a % columns);
-  const int y0 = iy0 - 1 + (side - 1) * (a / columns);
-  const int x1 = x0 + side - 1;
-  const int y1 = y0 + side - 1;
-  if (c == WINBG)
-  {
-    set_colour (c);
-    DrawScreenRect (x0, y0, side, side);
-  }
-  else
-  {
-    const int l1 = side / 2;
-    const int l2 = side - l1;
-    // FIXME this cursor looks ugly
-    set_colour (phase ? BLACK : WHITE);
-    DrawScreenLineLen (x0, y0,  l1,   0);
-    DrawScreenLineLen (x0, y0,   0,  l1);
-    DrawScreenLineLen (x1, y1,   0, -l1);
-    DrawScreenLineLen (x1, y1, -l1,   0);
-    set_colour (phase ? WHITE : BLACK);
-    DrawScreenLineLen (x1, y0, -l2,   0);
-    DrawScreenLineLen (x1, y0,   0,  l2);
-    DrawScreenLineLen (x0, y1,   0, -l2);
-    DrawScreenLineLen (x0, y1,  l2,   0);
-  }
+    const int a = (i + ncolours - ofs) % ncolours;
+    const int side = pixels + 2;
+    const int x0 = ix0 - 1 + (side - 1) * (a % columns);
+    const int y0 = iy0 - 1 + (side - 1) * (a / columns);
+    const int x1 = x0 + side - 1;
+    const int y1 = y0 + side - 1;
+    if (c == WINBG)
+    {
+	set_colour(c);
+	DrawScreenRect(x0, y0, side, side);
+    }
+    else
+    {
+	const int l1 = side / 2;
+	const int l2 = side - l1;
+	// FIXME this cursor looks ugly
+	set_colour(phase ? BLACK : WHITE);
+	DrawScreenLineLen(x0, y0, l1, 0);
+	DrawScreenLineLen(x0, y0, 0, l1);
+	DrawScreenLineLen(x1, y1, 0, -l1);
+	DrawScreenLineLen(x1, y1, -l1, 0);
+	set_colour(phase ? WHITE : BLACK);
+	DrawScreenLineLen(x1, y0, -l2, 0);
+	DrawScreenLineLen(x1, y0, 0, l2);
+	DrawScreenLineLen(x0, y1, 0, -l2);
+	DrawScreenLineLen(x0, y1, l2, 0);
+    }
 }
-
-
--- a/src/palview.h	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/palview.h	Sat Sep 24 14:16:04 2011 +0300
@@ -11,19 +11,17 @@
 
 class Palette_viewer
 {
-  public :
-    void run ();
+    public:void run();
 
-  private :
-    void draw_cursor (int c, bool phase);
+      private: void draw_cursor(int c, bool phase);
 
     static const int ncolours = DOOM_COLOURS;
-    static const int pixels   = 16;
-    static const int columns  = 16;
-    int              i;
-    int              ofs;
-    int              ix0;
-    int              iy0;
+    static const int pixels = 16;
+    static const int columns = 16;
+    int i;
+    int ofs;
+    int ix0;
+    int iy0;
 };
 
 
--- a/src/patchdir.cc	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/patchdir.cc	Sat Sep 24 14:16:04 2011 +0300
@@ -46,188 +46,188 @@
 /*
  *	ctor
  */
-Patch_dir::Patch_dir ()
+Patch_dir::Patch_dir()
 {
-  pnames = 0;
-  npnames = 0;
+    pnames = 0;
+    npnames = 0;
 }
 
 
 /*
  *	dtor
  */
-Patch_dir::~Patch_dir ()
+Patch_dir::~Patch_dir()
 {
-  if (pnames != 0)
-    FreeMemory (pnames);
-  if (! patch_lumps.empty ())
-    patch_lumps.clear ();
+    if (pnames != 0)
+	FreeMemory(pnames);
+    if (!patch_lumps.empty())
+	patch_lumps.clear();
 }
 
 
 /*
  *	Patch_dir::refresh
  */
-void Patch_dir::refresh (MDirPtr master_dir)
+void Patch_dir::refresh(MDirPtr master_dir)
 {
-  /* refresh() can be called more than once on the same object.
-     And usually is ! */
-  if (pnames != 0)
-  {
-    FreeMemory (pnames);
-    pnames = 0;
-    npnames = 0;
-  }
-  if (! patch_lumps.empty ())
-    patch_lumps.clear ();
+    /* refresh() can be called more than once on the same object.
+       And usually is ! */
+    if (pnames != 0)
+    {
+	FreeMemory(pnames);
+	pnames = 0;
+	npnames = 0;
+    }
+    if (!patch_lumps.empty())
+	patch_lumps.clear();
 
-  /* First load PNAMES so that we known in which order we should
-     put the patches in the array. */
-  {
-    bool success = false;
-    const char *lump_name = "PNAMES";
-    do
+    /* First load PNAMES so that we known in which order we should
+       put the patches in the array. */
     {
-      MDirPtr dir;
-      i32 npatches_head = -42;
-      i32 npatches_body = -42;
+	bool success = false;
+	const char *lump_name = "PNAMES";
+	do
+	{
+	    MDirPtr dir;
+	    i32 npatches_head = -42;
+	    i32 npatches_body = -42;
 
-      dir = FindMasterDir (master_dir, lump_name);
-      if (dir == 0)
-      {
-	warn ("No %s lump, won't be able to render textures\n", lump_name);
-	break;
-      }
-      i32 pnames_body_size = dir->dir.size - 4;
-      if (pnames_body_size < 0)
-      {
-	warn ("Bad %s (negative size %ld), won't be able to render textures\n",
-	    lump_name, (long) dir->dir.size);
-	break;
-      }
-      if (pnames_body_size % 8)
-      {
-	warn ("%s lump has weird size %ld, discarding last %d bytes\n",
-	    (long) dir->dir.size, (int) (pnames_body_size % 8));
-      }
-      npatches_body = pnames_body_size / 8;
-      const Wad_file *wf = dir->wadfile;
-      wf->seek (dir->dir.start);
-      if (wf->error ())
-      {
-	warn ("%s: seek error\n", lump_name);
-	break;
-      }
-      wf->read_i32 (&npatches_head);
-      if (wf->error ())
-      {
-	warn ("%s: error reading header\n", lump_name);
-	break;
-      }
-      if (npatches_head > 0 && npatches_head < npatches_body)
-	npnames = npatches_head;
-      else
-	npnames = npatches_body;
-      if (npatches_head != npatches_body)
-      {
-	warn("%s: header says %ld patches, lump size suggests %ld,"
-	    " going for %lu\n",
-	    lump_name, long (npatches_head), long (npatches_body),
-	    (unsigned long) npnames);
-      }
-      if (npnames > 32767)
-      {
-	warn ("%s: too big (%lu patches), keeping only first 32767\n",
-	    lump_name, (unsigned long) npnames);
-	npnames = 32767;
-      }
-      pnames = (char *) GetMemory (npnames * WAD_PIC_NAME);
-      wf->read_bytes (pnames, npnames * WAD_PIC_NAME);
-      if (wf->error ())
-      {
-	warn ("%s: error reading names\n", lump_name);
-	break;
-      }
-      success = true;
+	    dir = FindMasterDir(master_dir, lump_name);
+	    if (dir == 0)
+	    {
+		warn("No %s lump, won't be able to render textures\n",
+		     lump_name);
+		break;
+	    }
+	    i32 pnames_body_size = dir->dir.size - 4;
+	    if (pnames_body_size < 0)
+	    {
+		warn("Bad %s (negative size %ld), won't be able to render textures\n", lump_name, (long) dir->dir.size);
+		break;
+	    }
+	    if (pnames_body_size % 8)
+	    {
+		warn("%s lump has weird size %ld, discarding last %d bytes\n",
+		     (long) dir->dir.size, (int) (pnames_body_size % 8));
+	    }
+	    npatches_body = pnames_body_size / 8;
+	    const Wad_file *wf = dir->wadfile;
+	    wf->seek(dir->dir.start);
+	    if (wf->error())
+	    {
+		warn("%s: seek error\n", lump_name);
+		break;
+	    }
+	    wf->read_i32(&npatches_head);
+	    if (wf->error())
+	    {
+		warn("%s: error reading header\n", lump_name);
+		break;
+	    }
+	    if (npatches_head > 0 && npatches_head < npatches_body)
+		npnames = npatches_head;
+	    else
+		npnames = npatches_body;
+	    if (npatches_head != npatches_body)
+	    {
+		warn("%s: header says %ld patches, lump size suggests %ld,"
+		     " going for %lu\n",
+		     lump_name, long (npatches_head), long (npatches_body),
+		     (unsigned long) npnames);
+	    }
+	    if (npnames > 32767)
+	    {
+		warn("%s: too big (%lu patches), keeping only first 32767\n",
+		     lump_name, (unsigned long) npnames);
+		npnames = 32767;
+	    }
+	    pnames = (char *) GetMemory(npnames * WAD_PIC_NAME);
+	    wf->read_bytes(pnames, npnames * WAD_PIC_NAME);
+	    if (wf->error())
+	    {
+		warn("%s: error reading names\n", lump_name);
+		break;
+	    }
+	    success = true;
+	}
+	while (0);
+	if (!success)
+	    warn("%s: errors found, won't be able to render textures\n",
+		 lump_name);
     }
-    while (0);
-    if (! success)
-      warn ("%s: errors found, won't be able to render textures\n", lump_name);
-  }
 
-  /* Get list of patches in the master directory. Everything
-     that is between P_START/P_END or PP_START/PP_END and that
-     is not a label is supposed to be a patch. */
-  {
-    for (MDirPtr dir = master_dir;
-	dir && (dir = FindMasterDir (dir, "P_START", "PP_START"));)
+    /* Get list of patches in the master directory. Everything
+       that is between P_START/P_END or PP_START/PP_END and that
+       is not a label is supposed to be a patch. */
     {
-      MDirPtr start_label = dir;
-      const char *end_label = 0;
-      if (! y_strnicmp (dir->dir.name, "P_START", WAD_NAME))
-	end_label = "P_END";
-      else if (! y_strnicmp (dir->dir.name, "PP_START", WAD_NAME))
-	end_label = "PP_END";
-      else
-	fatal_error ("Bad start label \"%.*s\"", (int) WAD_NAME, dir->dir.name);
-      //printf ("[%-8.8s ", dir->dir.name);  // DEBUG
-      //fflush (stdout);
-      dir = dir->next;
-      for (;; dir = dir->next)
-      {
-	if (! dir)
-	{
-	  warn ("%.128s: no matching %s for %.*s\n",
-	      start_label->wadfile->pathname (),
-	      end_label,
-	      (int) WAD_NAME, start_label->dir.name);
-	  break;
-	}
-	if (! y_strnicmp (dir->dir.name, end_label, WAD_NAME))
+	for (MDirPtr dir = master_dir;
+	     dir && (dir = FindMasterDir(dir, "P_START", "PP_START"));)
 	{
-	  if (dir->dir.size != 0)
-	    warn ("%.128s: label %.*s has non-zero size %ld\n",
-		dir->wadfile->pathname (),
-		(int) WAD_NAME, dir->dir.name,
-		(long) dir->dir.size);
-	  dir = dir->next;
-	  //printf ("%-8.8s]\n", dir->dir.name);  // DEBUG
-	  break;
-	} 
-	if (dir->dir.start == 0 || dir->dir.size == 0)
-	{
-	  if (! (toupper (dir->dir.name[0]) == 'P'
-	      && (dir->dir.name[1] == '1'
-	       || dir->dir.name[1] == '2'
-	       || dir->dir.name[1] == '3')
-	      && dir->dir.name[2] == '_'
-	      && (! y_strnicmp (dir->dir.name + 3, "START", WAD_NAME - 3)
-		  || ! y_strnicmp (dir->dir.name + 3, "END", WAD_NAME - 3))))
-	    warn ("%.128s: unexpected label \"%.*s\" among patches.\n",
-		dir->wadfile->pathname (), (int) WAD_NAME, dir->dir.name);
-	  continue;
+	    MDirPtr start_label = dir;
+	    const char *end_label = 0;
+	    if (!y_strnicmp(dir->dir.name, "P_START", WAD_NAME))
+		end_label = "P_END";
+	    else if (!y_strnicmp(dir->dir.name, "PP_START", WAD_NAME))
+		end_label = "PP_END";
+	    else
+		fatal_error("Bad start label \"%.*s\"", (int) WAD_NAME,
+			    dir->dir.name);
+	    //printf ("[%-8.8s ", dir->dir.name);  // DEBUG
+	    //fflush (stdout);
+	    dir = dir->next;
+	    for (;; dir = dir->next)
+	    {
+		if (!dir)
+		{
+		    warn("%.128s: no matching %s for %.*s\n",
+			 start_label->wadfile->pathname(),
+			 end_label, (int) WAD_NAME, start_label->dir.name);
+		    break;
+		}
+		if (!y_strnicmp(dir->dir.name, end_label, WAD_NAME))
+		{
+		    if (dir->dir.size != 0)
+			warn("%.128s: label %.*s has non-zero size %ld\n",
+			     dir->wadfile->pathname(),
+			     (int) WAD_NAME, dir->dir.name,
+			     (long) dir->dir.size);
+		    dir = dir->next;
+		    //printf ("%-8.8s]\n", dir->dir.name);  // DEBUG
+		    break;
+		}
+		if (dir->dir.start == 0 || dir->dir.size == 0)
+		{
+		    if (!(toupper(dir->dir.name[0]) == 'P'
+			  && (dir->dir.name[1] == '1'
+			      || dir->dir.name[1] == '2'
+			      || dir->dir.name[1] == '3')
+			  && dir->dir.name[2] == '_'
+			  &&
+			  (!y_strnicmp
+			   (dir->dir.name + 3, "START", WAD_NAME - 3)
+			   || !y_strnicmp(dir->dir.name + 3, "END",
+					  WAD_NAME - 3))))
+			warn("%.128s: unexpected label \"%.*s\" among patches.\n", dir->wadfile->pathname(), (int) WAD_NAME, dir->dir.name);
+		    continue;
+		}
+		//printf ("%-9.8s ", dir->dir.name); fflush (stdout);  // DEBUG
+		wad_flat_name_t name;
+		memcpy(name, dir->dir.name, sizeof name);
+		patch_lumps[name]
+		    = Lump_loc(dir->wadfile, dir->dir.start, dir->dir.size);
+	    }
+	    if (dir)
+		dir = dir->next;
 	}
-	//printf ("%-9.8s ", dir->dir.name); fflush (stdout);  // DEBUG
-	wad_flat_name_t name;
-	memcpy (name, dir->dir.name, sizeof name);
-	patch_lumps[name]
-	  = Lump_loc (dir->wadfile, dir->dir.start, dir->dir.size);
-      }
-      if (dir)
-        dir = dir->next;
+	//putchar ('\n');  // DEBUG
     }
-    //putchar ('\n');  // DEBUG
-  }
 #ifdef DEBUG
-  for (Patch_lumps_map::const_iterator i = patch_lumps.begin ();
-      i != patch_lumps.end (); i++)
-  {
-    printf ("%-8.8s %p %08lX %ld\n",
-      i->first._name,
-      i->second.wad,
-      i->second.ofs,
-      i->second.len);
-  }
+    for (Patch_lumps_map::const_iterator i = patch_lumps.begin();
+	 i != patch_lumps.end(); i++)
+    {
+	printf("%-8.8s %p %08lX %ld\n",
+	       i->first._name, i->second.wad, i->second.ofs, i->second.len);
+    }
 #endif
 }
 
@@ -237,15 +237,15 @@
  *	Return the (wad, offset, length) location of the lump
  *	that contains patch <name>.
  */
-void Patch_dir::loc_by_name (const char *name, Lump_loc& loc)
+void Patch_dir::loc_by_name(const char *name, Lump_loc & loc)
 {
-  Patch_lumps_map::const_iterator i = patch_lumps.find (name);
-  if (i == patch_lumps.end ())
-  {
-    loc.wad = 0;
-    return;
-  }
-  loc = i->second;
+    Patch_lumps_map::const_iterator i = patch_lumps.find(name);
+    if (i == patch_lumps.end())
+    {
+	loc.wad = 0;
+	return;
+    }
+    loc = i->second;
 }
 
 
@@ -254,15 +254,15 @@
  *	Return the (wad, offset, length) location of the lump
  *	that contains patch# <num>.
  */
-void Patch_dir::loc_by_num (i16 num, Lump_loc& loc)
+void Patch_dir::loc_by_num(i16 num, Lump_loc & loc)
 {
-  wad_pic_name_t *nm = name_for_num (num);
-  if (nm == 0)
-  {
-    loc.wad = 0;
-    return;
-  }
-  loc_by_name ((const char *) nm, loc);
+    wad_pic_name_t *nm = name_for_num(num);
+    if (nm == 0)
+    {
+	loc.wad = 0;
+	return;
+    }
+    loc_by_name((const char *) nm, loc);
 }
 
 
@@ -271,11 +271,11 @@
  *	Return a pointer on the name of the patch of number <num>
  *	or 0 if no such patch.
  */
-wad_pic_name_t *Patch_dir::name_for_num (i16 num)
+wad_pic_name_t *Patch_dir::name_for_num(i16 num)
 {
-  if (num < 0 || (size_t) num >= npnames)  // Cast to silence GCC warning
-    return 0;
-  return (wad_pic_name_t *) (pnames + WAD_PIC_NAME * num);
+    if (num < 0 || (size_t) num >= npnames)	// Cast to silence GCC warning
+	return 0;
+    return (wad_pic_name_t *) (pnames + WAD_PIC_NAME * num);
 }
 
 
@@ -284,82 +284,82 @@
  *	Put a list of all existing patch lump, sorted by name
  *	and without duplicates, in <pl>.
  */
-void Patch_dir::list (Patch_list& pl)
+void Patch_dir::list(Patch_list & pl)
 {
-  pl.set (patch_lumps);
+    pl.set(patch_lumps);
 }
 
 
 /*-------------------------- Patch_list --------------------------*/
 
 
-Patch_list::Patch_list ()
+Patch_list::Patch_list()
 {
-  array = 0;
-  nelements = 0;
+    array = 0;
+    nelements = 0;
 }
 
 
-Patch_list::~Patch_list ()
+Patch_list::~Patch_list()
 {
-  clear ();
+    clear();
 }
 
 
-void Patch_list::set (Patch_lumps_map& patch_lumps)
+void Patch_list::set(Patch_lumps_map & patch_lumps)
 {
-  clear ();
-  nelements = patch_lumps.size ();
-  array = new char *[nelements];
+    clear();
+    nelements = patch_lumps.size();
+    array = new char *[nelements];
 
-  Patch_lumps_map::const_iterator i = patch_lumps.begin ();
-  for (size_t n = 0; n < nelements; n++)
-  {
-    array[n] = new char[WAD_PIC_NAME + 1];
-    *array[n] = '\0';
-    strncat (array[n], i++->first._name, WAD_PIC_NAME);
-  }
+    Patch_lumps_map::const_iterator i = patch_lumps.begin();
+    for (size_t n = 0; n < nelements; n++)
+    {
+	array[n] = new char[WAD_PIC_NAME + 1];
+	*array[n] = '\0';
+	strncat(array[n], i++->first._name, WAD_PIC_NAME);
+    }
 }
 
 
-void Patch_list::clear ()
+void Patch_list::clear()
 {
-  if (array != 0)
-  {
-    for (size_t n = 0; n < nelements; n++)
-      delete[] array[n];
-    delete[] array;
-  }
+    if (array != 0)
+    {
+	for (size_t n = 0; n < nelements; n++)
+	    delete[]array[n];
+	delete[]array;
+    }
 }
 
 
-const char **Patch_list::data ()
+const char **Patch_list::data()
 {
-  return (const char **) array;
+    return (const char **) array;
 }
 
 
-size_t Patch_list::size ()
+size_t Patch_list::size()
 {
-  return nelements;
+    return nelements;
 }
 
 
 /*---------------------------- Pllik -----------------------------*/
 
 
-Pllik::Pllik (const char *name)
+Pllik::Pllik(const char *name)
 {
-  memcpy (_name, name, sizeof _name);
+    memcpy(_name, name, sizeof _name);
 }
 
 
 /*-------------------------- Pllik_less --------------------------*/
 
 
-bool Pllik_less::operator () (const Pllik &p1, const Pllik &p2) const
-{
-  return y_strnicmp ((const char *) &p1, (const char *) &p2, WAD_PIC_NAME) < 0;
-}
-
-
+bool Pllik_less::operator () (const Pllik & p1, const Pllik & p2)
+     const
+     {
+	 return y_strnicmp((const char *) &p1, (const char *) &p2,
+			   WAD_PIC_NAME) < 0;
+     }
--- a/src/patchdir.h	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/patchdir.h	Sat Sep 24 14:16:04 2011 +0300
@@ -76,54 +76,50 @@
 
 struct Pllik
 {
-  Pllik (const char *name);
-  wad_pic_name_t _name;
+    Pllik(const char *name);
+    wad_pic_name_t _name;
 };
 
 struct Pllik_less
 {
-  bool operator() (const Pllik& p1, const Pllik& p2) const;
+    bool operator() (const Pllik & p1, const Pllik & p2) const;
 };
 
-typedef std::map<Pllik, Lump_loc, Pllik_less> Patch_lumps_map;
+typedef std::map < Pllik, Lump_loc, Pllik_less > Patch_lumps_map;
 
 class Patch_list
 {
-  public :
-    Patch_list ();
-    ~Patch_list ();
-    const char **data ();
-    size_t size ();
-    void set (Patch_lumps_map& patch_lumps);
-    void clear ();
+    public: Patch_list();
+    ~Patch_list();
+    const char **data();
+    size_t size();
+    void set(Patch_lumps_map & patch_lumps);
+    void clear();
 
-  private :
-    char **array;
+    private: char **array;
     size_t nelements;
 };
 
 class Patch_dir
 {
-  public :
-    Patch_dir ();
-    ~Patch_dir ();
-    void refresh (MDirPtr master_dir);
-    void loc_by_name (const char *name, Lump_loc& loc);
-    void loc_by_num (i16 num, Lump_loc& loc);
-    wad_pic_name_t *name_for_num (i16 num);
-    void list (Patch_list& pl);
+    public: Patch_dir();
+    ~Patch_dir();
+    void refresh(MDirPtr master_dir);
+    void loc_by_name(const char *name, Lump_loc & loc);
+    void loc_by_num(i16 num, Lump_loc & loc);
+    wad_pic_name_t *name_for_num(i16 num);
+    void list(Patch_list & pl);
 
-  private :
-    char *pnames;			// The contents of PNAMES
-    					// (block of npnames x 8 chars)
-    size_t npnames;			// Number of entries in PNAMES
+    private: char *pnames;	// The contents of PNAMES
+    // (block of npnames x 8 chars)
+    size_t npnames;		// Number of entries in PNAMES
     Patch_lumps_map patch_lumps;	// List of patch lumps, sorted
-    					// by name (no duplicates), with
-					// their location.
+    // by name (no duplicates), with
+    // their location.
 };
 
 
-extern Patch_dir patch_dir;		// Only one instance and it's global
+extern Patch_dir patch_dir;	// Only one instance and it's global
 
 
-#endif  /* DO NOT ADD ANYTHING AFTER THIS LINE */
+#endif /* DO NOT ADD ANYTHING AFTER THIS LINE */
--- a/src/pic2img.cc	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/pic2img.cc	Sat Sep 24 14:16:04 2011 +0300
@@ -30,18 +30,19 @@
 
 
 #include "yadex.h"
-#include "gcolour2.h"  /* colour0 */
+#include "gcolour2.h"		/* colour0 */
 #include "pic2img.h"
 #include "wadfile.h"
 #include "wads.h"
 
 
-typedef enum { _MT_BADOFS, _MT_TOOLONG, _MT_TOOMANY } _msg_type_t;
+typedef enum
+{ _MT_BADOFS, _MT_TOOLONG, _MT_TOOMANY } _msg_type_t;
 
 
-static int add_msg (char type, int arg);
-static void do_add_msg (char type, int arg);
-static void flush_msg (const char *picname);
+static int add_msg(char type, int arg);
+static void do_add_msg(char type, int arg);
+static void flush_msg(const char *picname);
 
 
 /*
@@ -63,124 +64,123 @@
  *	If pic_y_offset == INT_MIN, the picture is centred vertically.
  */
 
-int LoadPicture (
-   Img& img,			// Game image to load picture into
-   const char *picname,		// Picture lump name
-   const Lump_loc& picloc,	// Picture lump location
-   int pic_x_offset,		// Coordinates of top left corner of picture
-   int pic_y_offset, 		// relative to top left corner of buffer
-   int *pic_width,		// To return the size of the picture
-   int *pic_height)		// (can be NULL)
+int LoadPicture(Img & img,	// Game image to load picture into
+		const char *picname,	// Picture lump name
+		const Lump_loc & picloc,	// Picture lump location
+		int pic_x_offset,	// Coordinates of top left corner of picture
+		int pic_y_offset,	// relative to top left corner of buffer
+		int *pic_width,	// To return the size of the picture
+		int *pic_height)	// (can be NULL)
 {
-MDirPtr	dir;
-i16	pic_width_;
-i16	pic_height_;
-i16	pic_intrinsic_x_ofs;
-i16	pic_intrinsic_y_ofs;
-u8	*ColumnData;
-u8	*Column;
-i32	*NeededOffsets;
-i32	CurrentOffset;
-int	ColumnInMemory;
-long	ActualBufLen;
-int	pic_x;
-int	pic_x0;
-int	pic_x1;
-int	pic_y0;
-int	pic_y1;
-u8      *buf;	/* This variable is set to point to the element of
-		   the image buffer where the top of the current column
-		   should be pasted. It can be off the image buffer! */
+    MDirPtr dir;
+    i16 pic_width_;
+    i16 pic_height_;
+    i16 pic_intrinsic_x_ofs;
+    i16 pic_intrinsic_y_ofs;
+    u8 *ColumnData;
+    u8 *Column;
+    i32 *NeededOffsets;
+    i32 CurrentOffset;
+    int ColumnInMemory;
+    long ActualBufLen;
+    int pic_x;
+    int pic_x0;
+    int pic_x1;
+    int pic_y0;
+    int pic_y1;
+    u8 *buf;			/* This variable is set to point to the element of
+				   the image buffer where the top of the current column
+				   should be pasted. It can be off the image buffer! */
 
 // Locate the lump where the picture is
-if (picloc.wad != 0)
-   {
-   MasterDirectory dirbuf;
-   dirbuf.wadfile   = picloc.wad;
-   dirbuf.dir.start = picloc.ofs;
-   dirbuf.dir.size  = picloc.len;
-   dir = &dirbuf;
-   }
-else
-   {
-   dir = (MDirPtr) FindMasterDir (MasterDir, picname);
-   if (dir == NULL)
-      {
-      warn ("picture %.*s does not exist.\n", WAD_PIC_NAME, picname);
-      return 1;
-      }
-   }
+    if (picloc.wad != 0)
+    {
+	MasterDirectory dirbuf;
+	dirbuf.wadfile = picloc.wad;
+	dirbuf.dir.start = picloc.ofs;
+	dirbuf.dir.size = picloc.len;
+	dir = &dirbuf;
+    }
+    else
+    {
+	dir = (MDirPtr) FindMasterDir(MasterDir, picname);
+	if (dir == NULL)
+	{
+	    warn("picture %.*s does not exist.\n", WAD_PIC_NAME, picname);
+	    return 1;
+	}
+    }
 
 // Read the picture header
-dir->wadfile->seek (dir->dir.start);
-if (dir->wadfile->error ())
-   {
-   warn ("picture %.*s: can't seek to header, giving up\n",
-         WAD_PIC_NAME, picname);
-   return 1;
-   }
-bool dummy_bytes  = dir->wadfile->pic_format () == YGPF_NORMAL;
-bool long_header  = dir->wadfile->pic_format () != YGPF_ALPHA;
-bool long_offsets = dir->wadfile->pic_format () == YGPF_NORMAL;
-if (long_header)
-   {
-   dir->wadfile->read_i16 (&pic_width_);
-   dir->wadfile->read_i16 (&pic_height_);
-   dir->wadfile->read_i16 (&pic_intrinsic_x_ofs);  // Read but ignored
-   dir->wadfile->read_i16 (&pic_intrinsic_y_ofs);  // Read but ignored
-   if (dir->wadfile->error ())
-      {
-      warn ("picture %.*s: read error in header, giving up\n",
-	    WAD_PIC_NAME, picname);
-      return 1;
-      }
-   }
-else
-   {
-   pic_width_          = dir->wadfile->read_u8 ();
-   pic_height_         = dir->wadfile->read_u8 ();
-   pic_intrinsic_x_ofs = dir->wadfile->read_u8 ();  // Read but ignored
-   pic_intrinsic_y_ofs = dir->wadfile->read_u8 ();  // Read but ignored
-   if (dir->wadfile->error ())
-      {
-      warn ("picture %.*s: read error in header, giving up\n",
-	    WAD_PIC_NAME, picname);
-      return 1;
-      }
-   }
+    dir->wadfile->seek(dir->dir.start);
+    if (dir->wadfile->error())
+    {
+	warn("picture %.*s: can't seek to header, giving up\n",
+	     WAD_PIC_NAME, picname);
+	return 1;
+    }
+    bool dummy_bytes = dir->wadfile->pic_format() == YGPF_NORMAL;
+    bool long_header = dir->wadfile->pic_format() != YGPF_ALPHA;
+    bool long_offsets = dir->wadfile->pic_format() == YGPF_NORMAL;
+    if (long_header)
+    {
+	dir->wadfile->read_i16(&pic_width_);
+	dir->wadfile->read_i16(&pic_height_);
+	dir->wadfile->read_i16(&pic_intrinsic_x_ofs);	// Read but ignored
+	dir->wadfile->read_i16(&pic_intrinsic_y_ofs);	// Read but ignored
+	if (dir->wadfile->error())
+	{
+	    warn("picture %.*s: read error in header, giving up\n",
+		 WAD_PIC_NAME, picname);
+	    return 1;
+	}
+    }
+    else
+    {
+	pic_width_ = dir->wadfile->read_u8();
+	pic_height_ = dir->wadfile->read_u8();
+	pic_intrinsic_x_ofs = dir->wadfile->read_u8();	// Read but ignored
+	pic_intrinsic_y_ofs = dir->wadfile->read_u8();	// Read but ignored
+	if (dir->wadfile->error())
+	{
+	    warn("picture %.*s: read error in header, giving up\n",
+		 WAD_PIC_NAME, picname);
+	    return 1;
+	}
+    }
 
 // If no buffer given by caller, allocate one.
-if (img.is_null ())
-   {
-   // Sanity checks
-   if (pic_width_  < 1 || pic_height_ < 1)
-      {
-      warn ("picture %.*s: delirious dimensions %dx%d, giving up\n",
-	    WAD_PIC_NAME, picname, (int) pic_width_, (int) pic_height_);
-      }
-   const int pic_width_max = 4096;
-   if (pic_width_ > pic_width_max)
-      {
-      warn ("picture %.*s: too wide (%d), clipping to %d\n",
-	    WAD_PIC_NAME, picname, (int) pic_width_, pic_width_max);
-      pic_width_ = pic_width_max;
-      }
-   const int pic_height_max = 4096;
-   if (pic_height_ > pic_height_max)
-      {
-      warn ("picture %.*s: too high (%d), clipping to %d\n",
-	    WAD_PIC_NAME, picname, (int) pic_height_, pic_height_max);
-      pic_height_ = pic_height_max;
-      }
-   img.resize (pic_width_, pic_height_);
-   }
-int img_width = img.width ();
+    if (img.is_null())
+    {
+	// Sanity checks
+	if (pic_width_ < 1 || pic_height_ < 1)
+	{
+	    warn("picture %.*s: delirious dimensions %dx%d, giving up\n",
+		 WAD_PIC_NAME, picname, (int) pic_width_, (int) pic_height_);
+	}
+	const int pic_width_max = 4096;
+	if (pic_width_ > pic_width_max)
+	{
+	    warn("picture %.*s: too wide (%d), clipping to %d\n",
+		 WAD_PIC_NAME, picname, (int) pic_width_, pic_width_max);
+	    pic_width_ = pic_width_max;
+	}
+	const int pic_height_max = 4096;
+	if (pic_height_ > pic_height_max)
+	{
+	    warn("picture %.*s: too high (%d), clipping to %d\n",
+		 WAD_PIC_NAME, picname, (int) pic_height_, pic_height_max);
+	    pic_height_ = pic_height_max;
+	}
+	img.resize(pic_width_, pic_height_);
+    }
+    int img_width = img.width();
 
 // Centre the picture.
-if (pic_x_offset == INT_MIN)
-   pic_x_offset = (img_width - pic_width_) / 2;
-if (pic_y_offset == INT_MIN)
-   pic_y_offset = (img.height () - pic_height_) / 2;
+    if (pic_x_offset == INT_MIN)
+	pic_x_offset = (img_width - pic_width_) / 2;
+    if (pic_y_offset == INT_MIN)
+	pic_y_offset = (img.height() - pic_height_) / 2;
 
 /* AYM 19971202: 17 kB is large enough for 128x128 patches. */
 #define TEX_COLUMNBUFFERSIZE ((long) 17 * 1024)
@@ -190,182 +190,183 @@
    (255 x 5 + 1) = 1276 bytes per column. */
 #define TEX_COLUMNSIZE  1300
 
-ColumnData    = (u8 *) GetMemory (TEX_COLUMNBUFFERSIZE);
+    ColumnData = (u8 *) GetMemory(TEX_COLUMNBUFFERSIZE);
 /* FIXME DOS and pic_width_ > 16000 */
-NeededOffsets = (i32 *) GetMemory ((long) pic_width_ * 4);
+    NeededOffsets = (i32 *) GetMemory((long) pic_width_ * 4);
 
-if (long_offsets)
-   dir->wadfile->read_i32 (NeededOffsets, pic_width_);
-else
-   for (int n = 0; n < pic_width_; n++)
-      {
-      i16 ofs;
-      dir->wadfile->read_i16 (&ofs);
-      NeededOffsets[n] = ofs;
-      }
-if (dir->wadfile->error ())
-   {
-   warn ("picture %.*s: read error in offset table, giving up\n",
-	 WAD_PIC_NAME, picname);
-   FreeMemory (ColumnData);
-   FreeMemory (NeededOffsets);
-   return 1;
-   }
+    if (long_offsets)
+	dir->wadfile->read_i32(NeededOffsets, pic_width_);
+    else
+	for (int n = 0; n < pic_width_; n++)
+	{
+	    i16 ofs;
+	    dir->wadfile->read_i16(&ofs);
+	    NeededOffsets[n] = ofs;
+	}
+    if (dir->wadfile->error())
+    {
+	warn("picture %.*s: read error in offset table, giving up\n",
+	     WAD_PIC_NAME, picname);
+	FreeMemory(ColumnData);
+	FreeMemory(NeededOffsets);
+	return 1;
+    }
 
 // Read first column data, and subsequent column data
-if (long_offsets && NeededOffsets[0] != 8 + (long) pic_width_ * 4
-|| !long_offsets && NeededOffsets[0] != 4 + (long) pic_width_ * 2)
-   {
-   dir->wadfile->seek (dir->dir.start + NeededOffsets[0]);
-   if (dir->wadfile->error ())
-      {
-      warn ("picture %.*s: can't seek to header, giving up\n",
-         WAD_PIC_NAME, picname);
-      FreeMemory (ColumnData);
-      FreeMemory (NeededOffsets);
-      return 1;
-      }
-   }
-ActualBufLen = dir->wadfile->read_vbytes (ColumnData, TEX_COLUMNBUFFERSIZE);
+    if (long_offsets && NeededOffsets[0] != 8 + (long) pic_width_ * 4
+	|| !long_offsets && NeededOffsets[0] != 4 + (long) pic_width_ * 2)
+    {
+	dir->wadfile->seek(dir->dir.start + NeededOffsets[0]);
+	if (dir->wadfile->error())
+	{
+	    warn("picture %.*s: can't seek to header, giving up\n",
+		 WAD_PIC_NAME, picname);
+	    FreeMemory(ColumnData);
+	    FreeMemory(NeededOffsets);
+	    return 1;
+	}
+    }
+    ActualBufLen =
+	dir->wadfile->read_vbytes(ColumnData, TEX_COLUMNBUFFERSIZE);
 // FIXME should catch I/O errors
 
 // Clip the picture horizontally and vertically
-pic_x0 = - pic_x_offset;
-if (pic_x0 < 0)
-  pic_x0 = 0;
+    pic_x0 = -pic_x_offset;
+    if (pic_x0 < 0)
+	pic_x0 = 0;
 
-pic_x1 = img_width - pic_x_offset - 1;
-if (pic_x1 >= pic_width_)
-  pic_x1 = pic_width_ - 1;
+    pic_x1 = img_width - pic_x_offset - 1;
+    if (pic_x1 >= pic_width_)
+	pic_x1 = pic_width_ - 1;
 
-pic_y0 = - pic_y_offset;
-if (pic_y0 < 0)
-  pic_y0 = 0;
+    pic_y0 = -pic_y_offset;
+    if (pic_y0 < 0)
+	pic_y0 = 0;
 
-pic_y1 = img.height () - pic_y_offset - 1;
-if (pic_y1 >= pic_height_)
-  pic_y1 = pic_height_ - 1;
+    pic_y1 = img.height() - pic_y_offset - 1;
+    if (pic_y1 >= pic_height_)
+	pic_y1 = pic_height_ - 1;
 
 // For each (non clipped) column of the picture...
-for (pic_x = pic_x0,
-   buf = img.wbuf () + al_amax (pic_x_offset, 0) + img_width * pic_y_offset;
-   pic_x <= pic_x1;
-   pic_x++, buf++)
-   {
-   u8 *filedata;
+    for (pic_x = pic_x0,
+	 buf =
+	 img.wbuf() + al_amax(pic_x_offset, 0) + img_width * pic_y_offset;
+	 pic_x <= pic_x1; pic_x++, buf++)
+    {
+	u8 *filedata;
 
-   CurrentOffset  = NeededOffsets[pic_x];
-   ColumnInMemory = CurrentOffset >= NeededOffsets[0]
-      && CurrentOffset + TEX_COLUMNSIZE <= NeededOffsets[0] + ActualBufLen;
-   if (ColumnInMemory)
-      Column = ColumnData + CurrentOffset - NeededOffsets[0];
-   else
-      {
-      Column = (u8 *) GetMemory (TEX_COLUMNSIZE);
-      dir->wadfile->seek (dir->dir.start + CurrentOffset);
-      if (dir->wadfile->error ())
-         {
-	 int too_many = add_msg (_MT_BADOFS, (short) pic_x);
-	 FreeMemory (Column);
-	 if (too_many)		// This picture has too many errors. Give up.
-	    goto pic_end;
-	 continue;			// Give up on this column
-         }
-      dir->wadfile->read_vbytes (Column, TEX_COLUMNSIZE);
-      // FIXME should catch I/O errors
-      }
-   filedata = Column;
+	CurrentOffset = NeededOffsets[pic_x];
+	ColumnInMemory = CurrentOffset >= NeededOffsets[0]
+	    && CurrentOffset + TEX_COLUMNSIZE <=
+	    NeededOffsets[0] + ActualBufLen;
+	if (ColumnInMemory)
+	    Column = ColumnData + CurrentOffset - NeededOffsets[0];
+	else
+	{
+	    Column = (u8 *) GetMemory(TEX_COLUMNSIZE);
+	    dir->wadfile->seek(dir->dir.start + CurrentOffset);
+	    if (dir->wadfile->error())
+	    {
+		int too_many = add_msg(_MT_BADOFS, (short) pic_x);
+		FreeMemory(Column);
+		if (too_many)	// This picture has too many errors. Give up.
+		    goto pic_end;
+		continue;	// Give up on this column
+	    }
+	    dir->wadfile->read_vbytes(Column, TEX_COLUMNSIZE);
+	    // FIXME should catch I/O errors
+	}
+	filedata = Column;
+
+	// We now have the needed column data, one way or another, so write it
 
-   // We now have the needed column data, one way or another, so write it
- 
-   // For each post of the column...
-   {
-   register u8 *post;
-   for (post = filedata; *post != 0xff;)
-      {
-      int post_y_offset;	// Y-offset of top of post to origin of buffer
-      int post_height;		// Height of post
-      int post_pic_y0;		// Start and end of non-clipped part of post,
-      int post_pic_y1;		// relative to top of picture
-      int post_y0;		// Start and end of non-clipped part of post,
-      int post_y1;		// relative to top of post
-
-      if (post - filedata > TEX_COLUMNSIZE)
-         {
-	 int too_many = add_msg (_MT_TOOLONG, (short) pic_x);
-	 if (too_many)		// This picture has too many errors. Give up.
+	// For each post of the column...
+	{
+	    register u8 *post;
+	    for (post = filedata; *post != 0xff;)
 	    {
-	    if (! ColumnInMemory)
-	       FreeMemory (Column);
-	    goto pic_end;
-	    }
-	 break;				// Give up on this column
-	 }
+		int post_y_offset;	// Y-offset of top of post to origin of buffer
+		int post_height;	// Height of post
+		int post_pic_y0;	// Start and end of non-clipped part of post,
+		int post_pic_y1;	// relative to top of picture
+		int post_y0;	// Start and end of non-clipped part of post,
+		int post_y1;	// relative to top of post
 
-      post_y_offset = *post++;
-      post_height = *post++;
-      if (dummy_bytes)
-         post++;			// Skip that dummy byte
+		if (post - filedata > TEX_COLUMNSIZE)
+		{
+		    int too_many = add_msg(_MT_TOOLONG, (short) pic_x);
+		    if (too_many)	// This picture has too many errors. Give up.
+		    {
+			if (!ColumnInMemory)
+			    FreeMemory(Column);
+			goto pic_end;
+		    }
+		    break;	// Give up on this column
+		}
 
-      post_pic_y0 = post_y_offset;	// Clip the post vertically
-      if (post_pic_y0 < pic_y0)
-	 post_pic_y0 = pic_y0;
-      
-      post_pic_y1 = post_y_offset + post_height - 1;
-      if (post_pic_y1 > pic_y1)
-	 post_pic_y1 = pic_y1;
+		post_y_offset = *post++;
+		post_height = *post++;
+		if (dummy_bytes)
+		    post++;	// Skip that dummy byte
 
-      post_y0 = post_pic_y0 - post_y_offset;
-      post_y1 = post_pic_y1 - post_y_offset;
+		post_pic_y0 = post_y_offset;	// Clip the post vertically
+		if (post_pic_y0 < pic_y0)
+		    post_pic_y0 = pic_y0;
+
+		post_pic_y1 = post_y_offset + post_height - 1;
+		if (post_pic_y1 > pic_y1)
+		    post_pic_y1 = pic_y1;
+
+		post_y0 = post_pic_y0 - post_y_offset;
+		post_y1 = post_pic_y1 - post_y_offset;
 
 
-      {					// "Paste" the post onto the buffer
-      register img_pixel_t *b;
-      register const u8 *p          = post + post_y0;
-               const u8 *const pmax = post + post_y1;
-      int buf_width = img_width;
+		{		// "Paste" the post onto the buffer
+		    register img_pixel_t *b;
+		    register const u8 *p = post + post_y0;
+		    const u8 *const pmax = post + post_y1;
+		    int buf_width = img_width;
 
-      for (b = buf + buf_width * (post_y_offset + post_y0);
-	 p <= pmax;
-	 b += buf_width, p++)
-         {
+		    for (b = buf + buf_width * (post_y_offset + post_y0);
+			 p <= pmax; b += buf_width, p++)
+		    {
 #ifdef PARANOIA
-         if (b < img.buf ())
-	    {
-            nf_bug ("Picture %.*s(%d): b < buffer",
-		WAD_PIC_NAME, picname, (int) pic_x);
-	    goto next_column;
-	    }
+			if (b < img.buf())
+			{
+			    nf_bug("Picture %.*s(%d): b < buffer",
+				   WAD_PIC_NAME, picname, (int) pic_x);
+			    goto next_column;
+			}
 #endif
-	 *b = (*p == IMG_TRANSP) ? colour0 : *p;
-         }
-      }
+			*b = (*p == IMG_TRANSP) ? colour0 : *p;
+		    }
+		}
 
-      post += post_height;
-      if (dummy_bytes)
-         post++;			// Skip the trailing dummy byte
-      }  // Post loop
-   }
+		post += post_height;
+		if (dummy_bytes)
+		    post++;	// Skip the trailing dummy byte
+	    }			// Post loop
+	}
 
 #ifdef PARANOIA
-next_column :
+      next_column:
 #endif
-   if (!ColumnInMemory)
-      FreeMemory (Column);
-   }  // Column loop
+	if (!ColumnInMemory)
+	    FreeMemory(Column);
+    }				// Column loop
 
-pic_end:
-FreeMemory (ColumnData);
-FreeMemory (NeededOffsets);
-flush_msg (picname);
+  pic_end:
+    FreeMemory(ColumnData);
+    FreeMemory(NeededOffsets);
+    flush_msg(picname);
 #if 0
-c->flags |= HOOK_DRAWN;
+    c->flags |= HOOK_DRAWN;
 #endif
-if (pic_width)
-   *pic_width  = pic_width_;
-if (pic_height)
-   *pic_height = pic_height_;
-return 0;
+    if (pic_width)
+	*pic_width = pic_width_;
+    if (pic_height)
+	*pic_height = pic_height_;
+    return 0;
 }
 
 
@@ -374,13 +375,13 @@
  */
 typedef struct
 {
-   char type;
-   short arg;
+    char type;
+    short arg;
 } _msg_t;
-static _msg_t *_msg_list  = 0;
-static size_t _nmsg       = 0;
+static _msg_t *_msg_list = 0;
+static size_t _nmsg = 0;
 const size_t _granularity = 128;
-const size_t _max_msg     = 20;
+const size_t _max_msg = 20;
 
 
 /*
@@ -390,33 +391,35 @@
  *	Return 0 on success, <>0 if the max number of messages
  *	has been reached.
  */
-static int add_msg (char type, int arg)
+static int add_msg(char type, int arg)
 {
-if (_nmsg >= _max_msg)
-   {
-   if (_nmsg == _max_msg)  // Test in case the caller ignores our return value
-      do_add_msg (_MT_TOOMANY, arg);
-   return 1;
-   }
-do_add_msg (type, arg);
-return 0;
+    if (_nmsg >= _max_msg)
+    {
+	if (_nmsg == _max_msg)	// Test in case the caller ignores our return value
+	    do_add_msg(_MT_TOOMANY, arg);
+	return 1;
+    }
+    do_add_msg(type, arg);
+    return 0;
 }
 
 
-static void do_add_msg (char type, int arg)
+static void do_add_msg(char type, int arg)
 {
-if ((_nmsg + 1) % _granularity == 1)  // Grow list if necessary
-   {
-   _msg_t *new_list = (_msg_t *) realloc (_msg_list,
-	 (_nmsg / _granularity + 1) * _granularity * sizeof *_msg_list);
-   if (new_list == 0)  // Not enough memory ? Ignore the new message
-      return;
-   _msg_list = new_list;
-   }
-_msg_list[_nmsg].type = type;
-_msg_list[_nmsg].arg  = arg;
-_nmsg++;
-return;
+    if ((_nmsg + 1) % _granularity == 1)	// Grow list if necessary
+    {
+	_msg_t *new_list = (_msg_t *) realloc(_msg_list,
+					      (_nmsg / _granularity +
+					       1) * _granularity *
+					      sizeof *_msg_list);
+	if (new_list == 0)	// Not enough memory ? Ignore the new message
+	    return;
+	_msg_list = new_list;
+    }
+    _msg_list[_nmsg].type = type;
+    _msg_list[_nmsg].arg = arg;
+    _nmsg++;
+    return;
 }
 
 
@@ -424,63 +427,62 @@
  *	flush_msg
  *	Output all pending warning messages in an smart fashion
  */
-static void flush_msg (const char *picname)
+static void flush_msg(const char *picname)
 {
-if (_nmsg == 0 || _msg_list == 0)
-   return;
+    if (_nmsg == 0 || _msg_list == 0)
+	return;
 
-for (_msg_type_t t = _MT_BADOFS; t <= _MT_TOOLONG; ((int &) t)++)
-   {
-   size_t first_msg = AL_ASIZE_T_MAX;
-   size_t last_msg = AL_ASIZE_T_MAX;
-   const char *str = "unknown error";
-   if (t == _MT_BADOFS)
-      str = "bad file offset";
-   else if (t == _MT_TOOLONG)
-      str = "post too long";
+    for (_msg_type_t t = _MT_BADOFS; t <= _MT_TOOLONG; ((int &) t)++)
+    {
+	size_t first_msg = AL_ASIZE_T_MAX;
+	size_t last_msg = AL_ASIZE_T_MAX;
+	const char *str = "unknown error";
+	if (t == _MT_BADOFS)
+	    str = "bad file offset";
+	else if (t == _MT_TOOLONG)
+	    str = "post too long";
 
-   for (size_t n = 0; n < _nmsg; n++)
-      {
-      if (_msg_list[n].type == t)
-	 {
-	 if (first_msg == AL_ASIZE_T_MAX)
-	    {
-	    first_msg = n;
-	    last_msg = n;
-	    }
-	 else
+	for (size_t n = 0; n < _nmsg; n++)
+	{
+	    if (_msg_list[n].type == t)
 	    {
-	    if (_msg_list[last_msg].arg != _msg_list[n].arg - 1)
-	       {
-	       warn ("picture %.*s(%d",
-		  WAD_PIC_NAME, picname, (int) _msg_list[first_msg].arg);
-	       if (last_msg != first_msg)
-		  warn ("-%d", (int) _msg_list[last_msg].arg);
-	       warn ("): %s. Corrupt wad ?\n", str);
-	       first_msg = n;
-	       last_msg = n;
-	       }
-	    else
-	       last_msg = n;
+		if (first_msg == AL_ASIZE_T_MAX)
+		{
+		    first_msg = n;
+		    last_msg = n;
+		}
+		else
+		{
+		    if (_msg_list[last_msg].arg != _msg_list[n].arg - 1)
+		    {
+			warn("picture %.*s(%d",
+			     WAD_PIC_NAME, picname,
+			     (int) _msg_list[first_msg].arg);
+			if (last_msg != first_msg)
+			    warn("-%d", (int) _msg_list[last_msg].arg);
+			warn("): %s. Corrupt wad ?\n", str);
+			first_msg = n;
+			last_msg = n;
+		    }
+		    else
+			last_msg = n;
+		}
 	    }
-	 }
-      }
-   if (first_msg != AL_ASIZE_T_MAX)
-      {
-      warn ("picture %.*s(%d",
-	    WAD_PIC_NAME, picname, (int) _msg_list[first_msg].arg);
-      if (last_msg != first_msg)
-	 warn ("-%d", (int) _msg_list[last_msg].arg);
-      warn ("): %s. Corrupt wad ?\n", str);
-      }
-   }
+	}
+	if (first_msg != AL_ASIZE_T_MAX)
+	{
+	    warn("picture %.*s(%d",
+		 WAD_PIC_NAME, picname, (int) _msg_list[first_msg].arg);
+	    if (last_msg != first_msg)
+		warn("-%d", (int) _msg_list[last_msg].arg);
+	    warn("): %s. Corrupt wad ?\n", str);
+	}
+    }
 
-if (_msg_list[_nmsg - 1].type == _MT_TOOMANY)
-   warn ("picture %.*s: too many errors. Giving up.\n", WAD_PIC_NAME, picname);
-_nmsg = 0;
-free (_msg_list);
-_msg_list = 0;
+    if (_msg_list[_nmsg - 1].type == _MT_TOOMANY)
+	warn("picture %.*s: too many errors. Giving up.\n", WAD_PIC_NAME,
+	     picname);
+    _nmsg = 0;
+    free(_msg_list);
+    _msg_list = 0;
 }
-
-
-
--- a/src/pic2img.h	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/pic2img.h	Sat Sep 24 14:16:04 2011 +0300
@@ -4,7 +4,7 @@
  */
 
 
-#ifndef YH_PIC2IMG  /* DO NOT INSERT ANYTHING BEFORE THIS LINE */
+#ifndef YH_PIC2IMG		/* DO NOT INSERT ANYTHING BEFORE THIS LINE */
 #define YH_PIC2IMG
 
 
@@ -18,19 +18,18 @@
 #define MAX_PICTURE_BUFFER_SIZE 100000
 
 
-int LoadPicture (
-   Img& img,
+int LoadPicture(Img & img,
 #if 0
-   img_pixel_t *buffer,	/* Buffer to load picture into */
-   int buf_width,		/* Dimensions of the buffer */
-   int buf_height,
+		img_pixel_t * buffer,	/* Buffer to load picture into */
+		int buf_width,	/* Dimensions of the buffer */
+		int buf_height,
 #endif
-   const char *picname,		/* Picture lump name */
-   const Lump_loc& picloc,	/* Picture lump name */
-   int pic_x_offset,		/* Coordinates of top left corner of picture */
-   int pic_y_offset,		/* relative to top left corner of buffer. */
-   int *pic_width = 0,		/* To return the size of the picture */
-   int *pic_height = 0);	/* (can be NULL) */
+		const char *picname,	/* Picture lump name */
+		const Lump_loc & picloc,	/* Picture lump name */
+		int pic_x_offset,	/* Coordinates of top left corner of picture */
+		int pic_y_offset,	/* relative to top left corner of buffer. */
+		int *pic_width = 0,	/* To return the size of the picture */
+		int *pic_height = 0);	/* (can be NULL) */
 
 
-#endif  /* DO NOT ADD ANYTHING AFTER THIS LINE */
+#endif /* DO NOT ADD ANYTHING AFTER THIS LINE */
--- a/src/prefer.cc	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/prefer.cc	Sat Sep 24 14:16:04 2011 +0300
@@ -41,123 +41,126 @@
    display a "Preferences" menu (change default textures, etc.)
 */
 
-void Preferences (int x0, int y0)
+void Preferences(int x0, int y0)
 {
-char   *menustr[9];
-int     n, val;
-char    texname[WAD_TEX_NAME + 1];
-char    flatname[WAD_FLAT_NAME + 1];
-int     width;
-int     height;
+    char *menustr[9];
+    int n, val;
+    char texname[WAD_TEX_NAME + 1];
+    char flatname[WAD_FLAT_NAME + 1];
+    int width;
+    int height;
 
-width  = 2 * BOX_BORDER + 2 * WIDE_HSPACING + 50 * FONTW;
-height = 2 * BOX_BORDER + 2 * WIDE_VSPACING + (int) (10.5 * FONTH);
-if (x0 < 0)
-   x0 = (ScrMaxX + 1 - width) / 2;
-if (y0 < 0)
-   y0 = (ScrMaxY + 1 - height) / 2;
-for (n = 0; n < 9; n++)
-   menustr[n] = (char *) GetMemory (80);
-sprintf (menustr[8], "Preferences");
-sprintf (menustr[0], "Change default middle texture  (Current: %.*s)",
-   (int) WAD_TEX_NAME, default_middle_texture);
-sprintf (menustr[1], "Change default upper texture   (Current: %.*s)",
-   (int) WAD_TEX_NAME, default_upper_texture);
-sprintf (menustr[2], "Change default lower texture   (Current: %.*s)",
-   (int) WAD_TEX_NAME, default_lower_texture);
-sprintf (menustr[3], "Change default floor texture   (Current: %.*s)",
-   (int) WAD_FLAT_NAME, default_floor_texture);
-sprintf (menustr[4], "Change default ceiling texture (Current: %.*s)",
-   (int) WAD_FLAT_NAME, default_ceiling_texture);
-sprintf (menustr[5], "Change default floor height    (Current: %d)",
-   default_floor_height);
-sprintf (menustr[6], "Change default ceiling height  (Current: %d)",
-   default_ceiling_height);
-sprintf (menustr[7], "Change default light level     (Current: %d)",
-   default_light_level);
-val = vDisplayMenu (x0, y0, menustr[8],
-  menustr[0], YK_, 0,
-  menustr[1], YK_, 0,
-  menustr[2], YK_, 0,
-  menustr[3], YK_, 0,
-  menustr[4], YK_, 0,
-  menustr[5], YK_, 0,
-  menustr[6], YK_, 0,
-  menustr[7], YK_, 0,
-  NULL);
-for (n = 0; n < 9; n++)
-   FreeMemory (menustr[n]);
-int subwin_x0 = x0 + BOX_BORDER + WIDE_HSPACING;
-int subwin_y0 = y0 + BOX_BORDER + WIDE_VSPACING + (int) ((1.5 + val) * FONTH);
-switch (val)
-   {
-   case 1:
-      strcpy (texname, default_middle_texture);
-      ChooseWallTexture (subwin_x0, subwin_y0, "Choose a wall texture",
-        NumWTexture, WTexture, texname);
-      if (strlen (texname) > 0)
-	 strcpy (default_middle_texture, texname);
-      break;
-   case 2:
-      strcpy (texname, default_upper_texture);
-      ChooseWallTexture (subwin_x0, subwin_y0, "Choose a wall texture",
-        NumWTexture, WTexture, texname);
-      if (strlen (texname) > 0)
-	 strcpy (default_upper_texture, texname);
-      break;
-   case 3:
-      strcpy (texname, default_lower_texture);
-      ChooseWallTexture (subwin_x0, subwin_y0, "Choose a wall texture",
-        NumWTexture, WTexture, texname);
-      if (strlen (texname) > 0)
-	 strcpy (default_lower_texture, texname);
-      break;
-   case 4:
-      {
-      strcpy (flatname, default_floor_texture);
-      char ** flat_names
-	= (char **) GetMemory (NumFTexture * sizeof *flat_names);
-      for (size_t n = 0; n < NumFTexture; n++)
-	 flat_names[n] = flat_list[n].name;
-      ChooseFloorTexture (subwin_x0, subwin_y0, "Choose a floor texture",
-        NumFTexture, flat_names, flatname);
-      FreeMemory (flat_names);
-      if (strlen (flatname) > 0)
-	 strcpy (default_floor_texture, flatname);
-      break;
-      }
-   case 5:
-      {
-      strcpy (flatname, default_ceiling_texture);
-      char ** flat_names
-	= (char **) GetMemory (NumFTexture * sizeof *flat_names);
-      for (size_t n = 0; n < NumFTexture; n++)
-	 flat_names[n] = flat_list[n].name;
-      ChooseFloorTexture (subwin_x0, subwin_y0, "Choose a ceiling texture",
-        NumFTexture, flat_names, flatname);
-      FreeMemory (flat_names);
-      if (strlen (flatname) > 0)
-	 strcpy (default_ceiling_texture, flatname);
-      break;
-      }
-   case 6:
-      val = InputIntegerValue (x0 + 42, subwin_y0, -512, 511, default_floor_height);
-      if (val != IIV_CANCEL)
-	 default_floor_height = val;
-      break;
-   case 7:
-      val = InputIntegerValue (x0 + 42, subwin_y0, -512, 511, default_ceiling_height);
-      if (val != IIV_CANCEL)
-	 default_ceiling_height = val;
-      break;
-   case 8:
-      val = InputIntegerValue (x0 + 42, subwin_y0, 0, 255, default_light_level);
-      if (val != IIV_CANCEL)
-	 default_light_level = val;
-      break;
-     
-   }
+    width = 2 * BOX_BORDER + 2 * WIDE_HSPACING + 50 * FONTW;
+    height = 2 * BOX_BORDER + 2 * WIDE_VSPACING + (int) (10.5 * FONTH);
+    if (x0 < 0)
+	x0 = (ScrMaxX + 1 - width) / 2;
+    if (y0 < 0)
+	y0 = (ScrMaxY + 1 - height) / 2;
+    for (n = 0; n < 9; n++)
+	menustr[n] = (char *) GetMemory(80);
+    sprintf(menustr[8], "Preferences");
+    sprintf(menustr[0], "Change default middle texture  (Current: %.*s)",
+	    (int) WAD_TEX_NAME, default_middle_texture);
+    sprintf(menustr[1], "Change default upper texture   (Current: %.*s)",
+	    (int) WAD_TEX_NAME, default_upper_texture);
+    sprintf(menustr[2], "Change default lower texture   (Current: %.*s)",
+	    (int) WAD_TEX_NAME, default_lower_texture);
+    sprintf(menustr[3], "Change default floor texture   (Current: %.*s)",
+	    (int) WAD_FLAT_NAME, default_floor_texture);
+    sprintf(menustr[4], "Change default ceiling texture (Current: %.*s)",
+	    (int) WAD_FLAT_NAME, default_ceiling_texture);
+    sprintf(menustr[5], "Change default floor height    (Current: %d)",
+	    default_floor_height);
+    sprintf(menustr[6], "Change default ceiling height  (Current: %d)",
+	    default_ceiling_height);
+    sprintf(menustr[7], "Change default light level     (Current: %d)",
+	    default_light_level);
+    val = vDisplayMenu(x0, y0, menustr[8],
+		       menustr[0], YK_, 0,
+		       menustr[1], YK_, 0,
+		       menustr[2], YK_, 0,
+		       menustr[3], YK_, 0,
+		       menustr[4], YK_, 0,
+		       menustr[5], YK_, 0,
+		       menustr[6], YK_, 0, menustr[7], YK_, 0, NULL);
+    for (n = 0; n < 9; n++)
+	FreeMemory(menustr[n]);
+    int subwin_x0 = x0 + BOX_BORDER + WIDE_HSPACING;
+    int subwin_y0 =
+	y0 + BOX_BORDER + WIDE_VSPACING + (int) ((1.5 + val) * FONTH);
+    switch (val)
+    {
+    case 1:
+	strcpy(texname, default_middle_texture);
+	ChooseWallTexture(subwin_x0, subwin_y0, "Choose a wall texture",
+			  NumWTexture, WTexture, texname);
+	if (strlen(texname) > 0)
+	    strcpy(default_middle_texture, texname);
+	break;
+    case 2:
+	strcpy(texname, default_upper_texture);
+	ChooseWallTexture(subwin_x0, subwin_y0, "Choose a wall texture",
+			  NumWTexture, WTexture, texname);
+	if (strlen(texname) > 0)
+	    strcpy(default_upper_texture, texname);
+	break;
+    case 3:
+	strcpy(texname, default_lower_texture);
+	ChooseWallTexture(subwin_x0, subwin_y0, "Choose a wall texture",
+			  NumWTexture, WTexture, texname);
+	if (strlen(texname) > 0)
+	    strcpy(default_lower_texture, texname);
+	break;
+    case 4:
+	{
+	    strcpy(flatname, default_floor_texture);
+	    char **flat_names
+		= (char **) GetMemory(NumFTexture * sizeof *flat_names);
+	    for (size_t n = 0; n < NumFTexture; n++)
+		flat_names[n] = flat_list[n].name;
+	    ChooseFloorTexture(subwin_x0, subwin_y0, "Choose a floor texture",
+			       NumFTexture, flat_names, flatname);
+	    FreeMemory(flat_names);
+	    if (strlen(flatname) > 0)
+		strcpy(default_floor_texture, flatname);
+	    break;
+	}
+    case 5:
+	{
+	    strcpy(flatname, default_ceiling_texture);
+	    char **flat_names
+		= (char **) GetMemory(NumFTexture * sizeof *flat_names);
+	    for (size_t n = 0; n < NumFTexture; n++)
+		flat_names[n] = flat_list[n].name;
+	    ChooseFloorTexture(subwin_x0, subwin_y0,
+			       "Choose a ceiling texture", NumFTexture,
+			       flat_names, flatname);
+	    FreeMemory(flat_names);
+	    if (strlen(flatname) > 0)
+		strcpy(default_ceiling_texture, flatname);
+	    break;
+	}
+    case 6:
+	val =
+	    InputIntegerValue(x0 + 42, subwin_y0, -512, 511,
+			      default_floor_height);
+	if (val != IIV_CANCEL)
+	    default_floor_height = val;
+	break;
+    case 7:
+	val =
+	    InputIntegerValue(x0 + 42, subwin_y0, -512, 511,
+			      default_ceiling_height);
+	if (val != IIV_CANCEL)
+	    default_ceiling_height = val;
+	break;
+    case 8:
+	val =
+	    InputIntegerValue(x0 + 42, subwin_y0, 0, 255,
+			      default_light_level);
+	if (val != IIV_CANCEL)
+	    default_light_level = val;
+	break;
+
+    }
 }
-
-
-
--- a/src/prefer.h	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/prefer.h	Sat Sep 24 14:16:04 2011 +0300
@@ -4,6 +4,4 @@
  */
 
 
-void Preferences (int x0, int y0);
-
-
+void Preferences(int x0, int y0);
--- a/src/r_images.cc	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/r_images.cc	Sat Sep 24 14:16:04 2011 +0300
@@ -32,7 +32,7 @@
 #include <X11/Xlib.h>
 #endif
 #include "dialog.h"
-#include "game.h"      /* yg_picture_format */
+#include "game.h"		/* yg_picture_format */
 #include "gfx.h"
 #include "levels.h"
 #include "lists.h"
@@ -54,11 +54,11 @@
  *	Function used by bsearch() to locate a particular 
  *	flat in the FTexture.
  */
-static int flat_list_entry_match (const void *key, const void *flat_list_entry)
+static int flat_list_entry_match(const void *key, const void *flat_list_entry)
 {
-return y_strnicmp ((const char *) key,
-      ((const flat_list_entry_t *) flat_list_entry)->name,
-      WAD_FLAT_NAME);
+    return y_strnicmp((const char *) key,
+		      ((const flat_list_entry_t *) flat_list_entry)->name,
+		      WAD_FLAT_NAME);
 }
 
 
@@ -66,30 +66,30 @@
  *  load a flat into a new image.  NULL if not found.
  */
 
-Img * Flat2Img (const wad_flat_name_t& fname)
+Img *Flat2Img(const wad_flat_name_t & fname)
 {
-char name[WAD_FLAT_NAME + 1];
-strncpy (name, fname, WAD_FLAT_NAME);
-name[WAD_FLAT_NAME] = 0;
+    char name[WAD_FLAT_NAME + 1];
+    strncpy(name, fname, WAD_FLAT_NAME);
+    name[WAD_FLAT_NAME] = 0;
 
-flat_list_entry_t *flat = (flat_list_entry_t *)
-   bsearch (name, flat_list, NumFTexture, sizeof *flat_list,
-         flat_list_entry_match);
+    flat_list_entry_t *flat = (flat_list_entry_t *)
+	bsearch(name, flat_list, NumFTexture, sizeof *flat_list,
+		flat_list_entry_match);
 
-if (! flat)  // Not found in list
-   return 0;
+    if (!flat)			// Not found in list
+	return 0;
 
-int width  = DOOM_FLAT_WIDTH;  // Big deal !
-int height = DOOM_FLAT_HEIGHT;
+    int width = DOOM_FLAT_WIDTH;	// Big deal !
+    int height = DOOM_FLAT_HEIGHT;
 
-const Wad_file *wadfile = flat->wadfile;
-wadfile->seek (flat->offset);
+    const Wad_file *wadfile = flat->wadfile;
+    wadfile->seek(flat->offset);
 
-Img *img = new Img (width, height, false);
+    Img *img = new Img(width, height, false);
 
-wadfile->read_bytes (img->wbuf (), (long) width * height);
+    wadfile->read_bytes(img->wbuf(), (long) width * height);
 
-return img;
+    return img;
 }
 
 
@@ -98,303 +98,305 @@
  * Returns NULL if not found or error.
  */
 
-Img * Tex2Img (const wad_tex_name_t& texname)
+Img *Tex2Img(const wad_tex_name_t & texname)
 {
-MDirPtr  dir = 0;	/* main directory pointer to the TEXTURE* entries */
-i32     *offsets;	/* array of offsets to texture names */
-int      n;		/* general counter */
-i16      width, height;	/* size of the texture */
-i16      npatches;	/* number of wall patches used to build this texture */
-i32      numtex;	/* number of texture names in TEXTURE* list */
-i32      texofs;	/* offset in the wad file to the texture data */
-char     tname[WAD_TEX_NAME + 1];	/* texture name */
-char     picname[WAD_PIC_NAME + 1];	/* wall patch name */
-bool     have_dummy_bytes;
-int      header_size;
-int      item_size;
+    MDirPtr dir = 0;		/* main directory pointer to the TEXTURE* entries */
+    i32 *offsets;		/* array of offsets to texture names */
+    int n;			/* general counter */
+    i16 width, height;		/* size of the texture */
+    i16 npatches;		/* number of wall patches used to build this texture */
+    i32 numtex;			/* number of texture names in TEXTURE* list */
+    i32 texofs;			/* offset in the wad file to the texture data */
+    char tname[WAD_TEX_NAME + 1];	/* texture name */
+    char picname[WAD_PIC_NAME + 1];	/* wall patch name */
+    bool have_dummy_bytes;
+    int header_size;
+    int item_size;
 
-char name[WAD_TEX_NAME + 1];
-strncpy (name, texname, WAD_TEX_NAME);
-name[WAD_TEX_NAME] = 0;
+    char name[WAD_TEX_NAME + 1];
+    strncpy(name, texname, WAD_TEX_NAME);
+    name[WAD_TEX_NAME] = 0;
 
 // Iwad-dependant details
-if (yg_texture_format == YGTF_NAMELESS)
-   {
-   have_dummy_bytes = true;
-   header_size      = 14;
-   item_size        = 10;
-   }
-else if (yg_texture_format == YGTF_NORMAL)
-   {
-   have_dummy_bytes = true;
-   header_size      = 14;
-   item_size        = 10;
-   }
-else if (yg_texture_format == YGTF_STRIFE11)
-   {
-   have_dummy_bytes = false;
-   header_size      = 10;
-   item_size        = 6;
-   }
-else
-   {
-   nf_bug ("Bad texture format %d.", (int) yg_texture_format);
-   return 0;
-   }
+    if (yg_texture_format == YGTF_NAMELESS)
+    {
+	have_dummy_bytes = true;
+	header_size = 14;
+	item_size = 10;
+    }
+    else if (yg_texture_format == YGTF_NORMAL)
+    {
+	have_dummy_bytes = true;
+	header_size = 14;
+	item_size = 10;
+    }
+    else if (yg_texture_format == YGTF_STRIFE11)
+    {
+	have_dummy_bytes = false;
+	header_size = 10;
+	item_size = 6;
+    }
+    else
+    {
+	nf_bug("Bad texture format %d.", (int) yg_texture_format);
+	return 0;
+    }
 
 /* offset for texture we want. */
-texofs = 0;
+    texofs = 0;
 // Doom alpha 0.4 : "TEXTURES", no names
-if (yg_texture_lumps == YGTL_TEXTURES && yg_texture_format == YGTF_NAMELESS)
-   {
-   dir = FindMasterDir (MasterDir, "TEXTURES");
-   if (dir != NULL)
-      {
-      dir->wadfile->seek (dir->dir.start);
-      dir->wadfile->read_i32 (&numtex);
-      if (WAD_TEX_NAME < 7) nf_bug ("WAD_TEX_NAME too small");  // Sanity
-      if (! y_strnicmp (name, "TEX", 3)
-            && isdigit (name[3])
-            && isdigit (name[4])
-            && isdigit (name[5])
-            && isdigit (name[6])
-            && name[7] == '\0')
-         {
-         long num;
-         if (sscanf (name + 3, "%4ld", &num) == 1
-               && num >= 0 && num < numtex)
-            {
-            dir->wadfile->seek (dir->dir.start + 4 + 4 * num);
-            dir->wadfile->read_i32 (&texofs);
-            texofs += dir->dir.start;
-            }
-         }
-      }
-   }
+    if (yg_texture_lumps == YGTL_TEXTURES
+	&& yg_texture_format == YGTF_NAMELESS)
+    {
+	dir = FindMasterDir(MasterDir, "TEXTURES");
+	if (dir != NULL)
+	{
+	    dir->wadfile->seek(dir->dir.start);
+	    dir->wadfile->read_i32(&numtex);
+	    if (WAD_TEX_NAME < 7)
+		nf_bug("WAD_TEX_NAME too small");	// Sanity
+	    if (!y_strnicmp(name, "TEX", 3)
+		&& isdigit(name[3])
+		&& isdigit(name[4])
+		&& isdigit(name[5]) && isdigit(name[6]) && name[7] == '\0')
+	    {
+		long num;
+		if (sscanf(name + 3, "%4ld", &num) == 1
+		    && num >= 0 && num < numtex)
+		{
+		    dir->wadfile->seek(dir->dir.start + 4 + 4 * num);
+		    dir->wadfile->read_i32(&texofs);
+		    texofs += dir->dir.start;
+		}
+	    }
+	}
+    }
 // Doom alpha 0.5 : only "TEXTURES"
-else if (yg_texture_lumps == YGTL_TEXTURES
-      && (yg_texture_format == YGTF_NORMAL || yg_texture_format == YGTF_STRIFE11))
-   {
-   // Is it in TEXTURES ?
-   dir = FindMasterDir (MasterDir, "TEXTURES");
-   if (dir != NULL)  // (Theoretically, it should always exist)
-      {
-      dir->wadfile->seek (dir->dir.start);
-      dir->wadfile->read_i32 (&numtex);
-      /* read in the offsets for texture1 names and info. */
-      offsets = (i32 *) GetMemory ((long) numtex * 4);
-      dir->wadfile->read_i32 (offsets, numtex);
-      for (n = 0; n < numtex && !texofs; n++)
-         {
-         dir->wadfile->seek (dir->dir.start + offsets[n]);
-         dir->wadfile->read_bytes (&tname, WAD_TEX_NAME);
-         if (!y_strnicmp (tname, name, WAD_TEX_NAME))
-            texofs = dir->dir.start + offsets[n];
-         }
-      FreeMemory (offsets);
-      }
-   }
+    else if (yg_texture_lumps == YGTL_TEXTURES
+	     && (yg_texture_format == YGTF_NORMAL
+		 || yg_texture_format == YGTF_STRIFE11))
+    {
+	// Is it in TEXTURES ?
+	dir = FindMasterDir(MasterDir, "TEXTURES");
+	if (dir != NULL)	// (Theoretically, it should always exist)
+	{
+	    dir->wadfile->seek(dir->dir.start);
+	    dir->wadfile->read_i32(&numtex);
+	    /* read in the offsets for texture1 names and info. */
+	    offsets = (i32 *) GetMemory((long) numtex * 4);
+	    dir->wadfile->read_i32(offsets, numtex);
+	    for (n = 0; n < numtex && !texofs; n++)
+	    {
+		dir->wadfile->seek(dir->dir.start + offsets[n]);
+		dir->wadfile->read_bytes(&tname, WAD_TEX_NAME);
+		if (!y_strnicmp(tname, name, WAD_TEX_NAME))
+		    texofs = dir->dir.start + offsets[n];
+	    }
+	    FreeMemory(offsets);
+	}
+    }
 // Other iwads : "TEXTURE1" and "TEXTURE2"
-else if (yg_texture_lumps == YGTL_NORMAL
-      && (yg_texture_format == YGTF_NORMAL || yg_texture_format == YGTF_STRIFE11))
-   {
-   // Is it in TEXTURE1 ?
-   dir = FindMasterDir (MasterDir, "TEXTURE1");
-   if (dir != NULL)  // (Theoretically, it should always exist)
-      {
-      dir->wadfile->seek (dir->dir.start);
-      dir->wadfile->read_i32 (&numtex);
-      /* read in the offsets for texture1 names and info. */
-      offsets = (i32 *) GetMemory ((long) numtex * 4);
-      dir->wadfile->read_i32 (offsets, numtex);
-      for (n = 0; n < numtex && !texofs; n++)
-         {
-         dir->wadfile->seek (dir->dir.start + offsets[n]);
-         dir->wadfile->read_bytes (&tname, WAD_TEX_NAME);
-         if (!y_strnicmp (tname, name, WAD_TEX_NAME))
-            texofs = dir->dir.start + offsets[n];
-         }
-      FreeMemory (offsets);
-      }
-   // Well, then is it in TEXTURE2 ?
-   if (texofs == 0)
-      {
-      dir = FindMasterDir (MasterDir, "TEXTURE2");
-      if (dir != NULL)  // Doom II has no TEXTURE2
-         {
-         dir->wadfile->seek (dir->dir.start);
-         dir->wadfile->read_i32 (&numtex);
-         /* read in the offsets for texture2 names */
-         offsets = (i32 *) GetMemory ((long) numtex * 4);
-         dir->wadfile->read_i32 (offsets, numtex);
-         for (n = 0; n < numtex && !texofs; n++)
-            {
-            dir->wadfile->seek (dir->dir.start + offsets[n]);
-            dir->wadfile->read_bytes (&tname, WAD_TEX_NAME);
-            if (!y_strnicmp (tname, name, WAD_TEX_NAME))
-               texofs = dir->dir.start + offsets[n];
-            }
-         FreeMemory (offsets);
-         }
-      }
-   }
-else
-   nf_bug ("Invalid texture_format/texture_lumps combination.");
+    else if (yg_texture_lumps == YGTL_NORMAL
+	     && (yg_texture_format == YGTF_NORMAL
+		 || yg_texture_format == YGTF_STRIFE11))
+    {
+	// Is it in TEXTURE1 ?
+	dir = FindMasterDir(MasterDir, "TEXTURE1");
+	if (dir != NULL)	// (Theoretically, it should always exist)
+	{
+	    dir->wadfile->seek(dir->dir.start);
+	    dir->wadfile->read_i32(&numtex);
+	    /* read in the offsets for texture1 names and info. */
+	    offsets = (i32 *) GetMemory((long) numtex * 4);
+	    dir->wadfile->read_i32(offsets, numtex);
+	    for (n = 0; n < numtex && !texofs; n++)
+	    {
+		dir->wadfile->seek(dir->dir.start + offsets[n]);
+		dir->wadfile->read_bytes(&tname, WAD_TEX_NAME);
+		if (!y_strnicmp(tname, name, WAD_TEX_NAME))
+		    texofs = dir->dir.start + offsets[n];
+	    }
+	    FreeMemory(offsets);
+	}
+	// Well, then is it in TEXTURE2 ?
+	if (texofs == 0)
+	{
+	    dir = FindMasterDir(MasterDir, "TEXTURE2");
+	    if (dir != NULL)	// Doom II has no TEXTURE2
+	    {
+		dir->wadfile->seek(dir->dir.start);
+		dir->wadfile->read_i32(&numtex);
+		/* read in the offsets for texture2 names */
+		offsets = (i32 *) GetMemory((long) numtex * 4);
+		dir->wadfile->read_i32(offsets, numtex);
+		for (n = 0; n < numtex && !texofs; n++)
+		{
+		    dir->wadfile->seek(dir->dir.start + offsets[n]);
+		    dir->wadfile->read_bytes(&tname, WAD_TEX_NAME);
+		    if (!y_strnicmp(tname, name, WAD_TEX_NAME))
+			texofs = dir->dir.start + offsets[n];
+		}
+		FreeMemory(offsets);
+	    }
+	}
+    }
+    else
+	nf_bug("Invalid texture_format/texture_lumps combination.");
 
 /* texture name not found */
-if (texofs == 0)
-   return 0;
+    if (texofs == 0)
+	return 0;
 
 /* read the info for this texture */
-i32 header_ofs;
-if (yg_texture_format == YGTF_NAMELESS)
-   header_ofs = texofs;
-else
-   header_ofs = texofs + WAD_TEX_NAME;
-dir->wadfile->seek (header_ofs + 4);
-dir->wadfile->read_i16 (&width);
-dir->wadfile->read_i16 (&height);
-if (have_dummy_bytes)
-   {
-   i16 dummy;
-   dir->wadfile->read_i16 (&dummy);
-   dir->wadfile->read_i16 (&dummy);
-   }
-dir->wadfile->read_i16 (&npatches);
+    i32 header_ofs;
+    if (yg_texture_format == YGTF_NAMELESS)
+	header_ofs = texofs;
+    else
+	header_ofs = texofs + WAD_TEX_NAME;
+    dir->wadfile->seek(header_ofs + 4);
+    dir->wadfile->read_i16(&width);
+    dir->wadfile->read_i16(&height);
+    if (have_dummy_bytes)
+    {
+	i16 dummy;
+	dir->wadfile->read_i16(&dummy);
+	dir->wadfile->read_i16(&dummy);
+    }
+    dir->wadfile->read_i16(&npatches);
 
 /* Compose the texture */
-Img *texbuf = new Img (width, height, false);
+    Img *texbuf = new Img(width, height, false);
 
 /* Paste onto the buffer all the patches that the texture is
    made of. */
-for (n = 0; n < npatches; n++)
-   {
-   i16 xofs, yofs;	// offset in texture space for the patch
-   i16 pnameind;	// index of patch in PNAMES
+    for (n = 0; n < npatches; n++)
+    {
+	i16 xofs, yofs;		// offset in texture space for the patch
+	i16 pnameind;		// index of patch in PNAMES
 
-   dir->wadfile->seek (header_ofs + header_size + (long) n * item_size);
-   dir->wadfile->read_i16 (&xofs);
-   dir->wadfile->read_i16 (&yofs);
-   dir->wadfile->read_i16 (&pnameind);
+	dir->wadfile->seek(header_ofs + header_size + (long) n * item_size);
+	dir->wadfile->read_i16(&xofs);
+	dir->wadfile->read_i16(&yofs);
+	dir->wadfile->read_i16(&pnameind);
 
-   if (have_dummy_bytes)
-      {
-      i16 stepdir;
-      i16 colormap;
-      dir->wadfile->read_i16 (&stepdir);   // Always 1, unused.
-      dir->wadfile->read_i16 (&colormap);  // Always 0, unused.
-      }
+	if (have_dummy_bytes)
+	{
+	    i16 stepdir;
+	    i16 colormap;
+	    dir->wadfile->read_i16(&stepdir);	// Always 1, unused.
+	    dir->wadfile->read_i16(&colormap);	// Always 0, unused.
+	}
 
-   /* AYM 1998-08-08: Yes, that's weird but that's what Doom
-      does. Without these two lines, the few textures that have
-      patches with negative y-offsets (BIGDOOR7, SKY1, TEKWALL1,
-      TEKWALL5 and a few others) would not look in the texture
-      viewer quite like in Doom. This should be mentioned in
-      the UDS, by the way. */
-   if (yofs < 0)
-      yofs = 0;
+	/* AYM 1998-08-08: Yes, that's weird but that's what Doom
+	   does. Without these two lines, the few textures that have
+	   patches with negative y-offsets (BIGDOOR7, SKY1, TEKWALL1,
+	   TEKWALL5 and a few others) would not look in the texture
+	   viewer quite like in Doom. This should be mentioned in
+	   the UDS, by the way. */
+	if (yofs < 0)
+	    yofs = 0;
 
-   Lump_loc loc;
-      {
-      wad_pic_name_t *wname = patch_dir.name_for_num (pnameind);
-      if (wname == 0)
-         {
-         warn ("texture \"%.*s\": patch %2d has bad index %d.\n",
-               WAD_TEX_NAME, tname, (int) n, (int) pnameind);
-         continue;
-         }
-      patch_dir.loc_by_name ((const char *) *wname, loc);
-      *picname = '\0';
-      strncat (picname, (const char *) *wname, sizeof picname - 1);
-      }
+	Lump_loc loc;
+	{
+	    wad_pic_name_t *wname = patch_dir.name_for_num(pnameind);
+	    if (wname == 0)
+	    {
+		warn("texture \"%.*s\": patch %2d has bad index %d.\n",
+		     WAD_TEX_NAME, tname, (int) n, (int) pnameind);
+		continue;
+	    }
+	    patch_dir.loc_by_name((const char *) *wname, loc);
+	    *picname = '\0';
+	    strncat(picname, (const char *) *wname, sizeof picname - 1);
+	}
 
-   if (LoadPicture (*texbuf, picname, loc, xofs, yofs, 0, 0))
-      warn ("texture \"%.*s\": patch \"%.*s\" not found.\n",
-            WAD_TEX_NAME, tname, WAD_PIC_NAME, picname);
-   }
+	if (LoadPicture(*texbuf, picname, loc, xofs, yofs, 0, 0))
+	    warn("texture \"%.*s\": patch \"%.*s\" not found.\n",
+		 WAD_TEX_NAME, tname, WAD_PIC_NAME, picname);
+    }
 
-return texbuf;
+    return texbuf;
 }
 
 
 /* --- ImageCache methods --- */
 
 
-Img *ImageCache::GetFlat (const wad_flat_name_t& fname)
+Img *ImageCache::GetFlat(const wad_flat_name_t & fname)
 {
-std::string f_str = WadToString(fname);
+    std::string f_str = WadToString(fname);
 
-flat_map_t::iterator P = flats.find (f_str);
+    flat_map_t::iterator P = flats.find(f_str);
 
-if (P != flats.end ())
-   return P->second;
+    if (P != flats.end())
+	return P->second;
 
 // flat not in the list yet.  Add it.
 
-Img *result = Flat2Img (fname);
-flats[f_str] = result;
+    Img *result = Flat2Img(fname);
+    flats[f_str] = result;
 
 // note that a NULL return from Flat2Img is OK, it means that no
 // such flat exists.  Our renderer will revert to using a solid
 // colour.
 
-return result;
+    return result;
 }
 
 
-Img *ImageCache::GetTex (const wad_tex_name_t& tname)
+Img *ImageCache::GetTex(const wad_tex_name_t & tname)
 {
-if (tname[0] == 0 || tname[0] == '-')
-   return 0;
+    if (tname[0] == 0 || tname[0] == '-')
+	return 0;
 
-std::string t_str = WadToString(tname);
+    std::string t_str = WadToString(tname);
 
-tex_map_t::iterator P = textures.find (t_str);
+    tex_map_t::iterator P = textures.find(t_str);
 
-if (P != textures.end ())
-   return P->second;
+    if (P != textures.end())
+	return P->second;
 
 // texture not in the list yet.  Add it.
 
-Img *result = Tex2Img (tname);
-textures[t_str] = result;
+    Img *result = Tex2Img(tname);
+    textures[t_str] = result;
 
 // note that a NULL return from Tex2Img is OK, it means that no
 // such texture exists.  Our renderer will revert to using a solid
 // colour.
 
-return result;
+    return result;
 }
 
 
-Img *ImageCache::GetSprite (const wad_ttype_t& type)
+Img *ImageCache::GetSprite(const wad_ttype_t & type)
 {
-sprite_map_t::iterator P = sprites.find (type);
+    sprite_map_t::iterator P = sprites.find(type);
 
-if (P != sprites.end ())
-   return P->second;
+    if (P != sprites.end())
+	return P->second;
 
 // sprite not in the list yet.  Add it.
 
-Img *result = 0;
+    Img *result = 0;
 
-const char *sprite_root = get_thing_sprite (type);
-if (sprite_root)
-   {
-   Lump_loc loc;
-   wad_res.sprites.loc_by_root (sprite_root, loc);
-   result = new Img ();
+    const char *sprite_root = get_thing_sprite(type);
+    if (sprite_root)
+    {
+	Lump_loc loc;
+	wad_res.sprites.loc_by_root(sprite_root, loc);
+	result = new Img();
 
-   if (LoadPicture (*result, sprite_root, loc, 0, 0) != 0)
-      {
-      delete result;
-      result = 0;
-      }
-   }
+	if (LoadPicture(*result, sprite_root, loc, 0, 0) != 0)
+	{
+	    delete result;
+	    result = 0;
+	}
+    }
 
 // note that a NULL image is OK.  Our renderer will just ignore the
 // missing sprite.
 
-sprites[type] = result;
-return result;
+    sprites[type] = result;
+    return result;
 }
--- a/src/r_images.h	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/r_images.h	Sat Sep 24 14:16:04 2011 +0300
@@ -4,7 +4,7 @@
  */
 
 
-#ifndef YH_R_IMAGES  /* DO NOT INSERT ANYTHING BEFORE THIS LINE */
+#ifndef YH_R_IMAGES		/* DO NOT INSERT ANYTHING BEFORE THIS LINE */
 #define YH_R_IMAGES
 
 
@@ -15,55 +15,56 @@
 
 struct ImageCache
 {
-public:
-   typedef std::map<std::string, Img *> flat_map_t;
-   typedef std::map<std::string, Img *> tex_map_t;
-   typedef std::map<wad_ttype_t, Img *> sprite_map_t;
+  public:
+    typedef std::map < std::string, Img * >flat_map_t;
+    typedef std::map < std::string, Img * >tex_map_t;
+    typedef std::map < wad_ttype_t, Img * >sprite_map_t;
 
-   flat_map_t   flats;
-   tex_map_t    textures;
-   sprite_map_t sprites;
+    flat_map_t flats;
+    tex_map_t textures;
+    sprite_map_t sprites;
 
-   static std::string WadToString(const wad_flat_name_t& fname)
-   {
-      int len;
+    static std::string WadToString(const wad_flat_name_t & fname)
+    {
+	int len;
+
+	for (len = 0; len < WAD_NAME && fname[len]; len++)
+	{
+	}
 
-      for (len = 0; len < WAD_NAME && fname[len]; len++)
-      { }
-        
-      return std::string(fname, len);
-   }
+	return std::string(fname, len);
+    }
 
-   static void DeleteFlat(const flat_map_t::value_type& P)
-      {
-      delete P.second;
-      }
+    static void DeleteFlat(const flat_map_t::value_type & P)
+    {
+	delete P.second;
+    }
 
-   static void DeleteTex(const tex_map_t::value_type& P)
-      {
-      delete P.second;
-      }
+    static void DeleteTex(const tex_map_t::value_type & P)
+    {
+	delete P.second;
+    }
 
-   static void DeleteSprite(const sprite_map_t::value_type& P)
-      {
-      delete P.second;
-      }
+    static void DeleteSprite(const sprite_map_t::value_type & P)
+    {
+	delete P.second;
+    }
 
-   ~ImageCache ()
-      {
-      std::for_each (flats.begin (), flats.end (), DeleteFlat);
-      std::for_each (textures.begin (), textures.end (), DeleteTex);
-      std::for_each (sprites.begin (), sprites.end (), DeleteSprite);
+    ~ImageCache()
+    {
+	std::for_each(flats.begin(), flats.end(), DeleteFlat);
+	std::for_each(textures.begin(), textures.end(), DeleteTex);
+	std::for_each(sprites.begin(), sprites.end(), DeleteSprite);
 
-      flats.clear ();
-      textures.clear ();
-      sprites.clear ();
-      }
+	flats.clear();
+	textures.clear();
+	sprites.clear();
+    }
 
-   Img *GetFlat   (const wad_flat_name_t& fname);
-   Img *GetTex    (const wad_tex_name_t& tname);
-   Img *GetSprite (const wad_ttype_t& type);
+    Img *GetFlat(const wad_flat_name_t & fname);
+    Img *GetTex(const wad_tex_name_t & tname);
+    Img *GetSprite(const wad_ttype_t & type);
 };
 
 
-#endif  /* DO NOT ADD ANYTHING AFTER THIS LINE */
+#endif /* DO NOT ADD ANYTHING AFTER THIS LINE */
--- a/src/r_render.cc	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/r_render.cc	Sat Sep 24 14:16:04 2011 +0300
@@ -63,88 +63,91 @@
 
 struct Y_View
 {
-public:
-   int p_type, px, py;
-   // player type and position.
+  public:
+    int p_type, px, py;
+    // player type and position.
 
-   float x, y; 
-   int z;
-   // view position.
+    float x, y;
+    int z;
+    // view position.
 
-   static const int EYE_HEIGHT = 41;
-   // standard height above the floor.
+    static const int EYE_HEIGHT = 41;
+    // standard height above the floor.
 
-   float angle;
-   float Sin, Cos;
-   // view direction.
+    float angle;
+    float Sin, Cos;
+    // view direction.
 
-   int sw, sh;
-   Img *screen;
-   // screen image.
+    int sw, sh;
+    Img *screen;
+    // screen image.
 
-   bool texturing;
-   bool sprites;
-   bool walking;
+    bool texturing;
+    bool sprites;
+    bool walking;
 
-   ImageCache *im_ch;
+    ImageCache *im_ch;
 
-   int *thing_floors;
+    int *thing_floors;
 
-   Y_View () { memset (this, 0, sizeof *this); }
+      Y_View()
+    {
+	memset(this, 0, sizeof *this);
+    }
 
-   void SetAngle (float new_ang)
-      {
-      angle = new_ang;
+    void SetAngle(float new_ang)
+    {
+	angle = new_ang;
 
-      if (angle >= TWOPI)
-         angle -= TWOPI;
-      else if (angle < 0)
-         angle += TWOPI;
+	if (angle >= TWOPI)
+	    angle -= TWOPI;
+	else if (angle < 0)
+	    angle += TWOPI;
 
-      Sin = sin (angle);
-      Cos = cos (angle);
-      }
+	Sin = sin(angle);
+	Cos = cos(angle);
+    }
 
-   void CalcViewZ ()
-      {
-        Objid o;
-        GetCurObject (o, OBJ_SECTORS, int (x), int (y));
-      int secnum = o.num;
-      if (secnum >= 0)
-         z = Sectors[secnum].floorh + EYE_HEIGHT;
-      }
+    void CalcViewZ()
+    {
+	Objid o;
+	GetCurObject(o, OBJ_SECTORS, int (x), int (y));
+	int secnum = o.num;
+	if (secnum >= 0)
+	    z = Sectors[secnum].floorh + EYE_HEIGHT;
+    }
 
-   void ClearScreen ()
-      {
-      memset (screen->wbuf (), colour0, sw * sh);
-      }
-
-   void PutScreen (int x, int y)
-      {
-      DrawScreenBox3D (x, y, x + BOX_BORDER*2 + sw, y + BOX_BORDER*2 + sh);
+    void ClearScreen()
+    {
+	memset(screen->wbuf(), colour0, sw * sh);
+    }
 
-      Sticker sticker (*screen, true);
+    void PutScreen(int x, int y)
+    {
+	DrawScreenBox3D(x, y, x + BOX_BORDER * 2 + sw,
+			y + BOX_BORDER * 2 + sh);
 
-      sticker.draw (drw, 't', x + BOX_BORDER, y + BOX_BORDER);
-      }
+	Sticker sticker(*screen, true);
 
-   void FindThingFloors ()
-   {
-   thing_floors = new int[NumThings];
+	sticker.draw(drw, 't', x + BOX_BORDER, y + BOX_BORDER);
+    }
 
-   for (int i = 0; i < NumThings; i++)
-      {
-        Objid o;
-        GetCurObject (o, OBJ_SECTORS, Things[i].xpos, 
-            Things[i].ypos);
-      int secnum = o.num;
-      
-      if (secnum < 0)
-         thing_floors[i] = 0;
-      else
-         thing_floors[i] = Sectors[secnum].floorh;
-      }
-   }
+    void FindThingFloors()
+    {
+	thing_floors = new int[NumThings];
+
+	for (int i = 0; i < NumThings; i++)
+	{
+	    Objid o;
+	    GetCurObject(o, OBJ_SECTORS, Things[i].xpos, Things[i].ypos);
+	    int secnum = o.num;
+
+	    if (secnum < 0)
+		thing_floors[i] = 0;
+	    else
+		thing_floors[i] = Sectors[secnum].floorh;
+	}
+    }
 };
 
 
@@ -153,970 +156,980 @@
 
 struct DrawSurf
 {
-public:
-   enum
-      {
-      K_INVIS = 0,
-      K_FLAT,
-      K_TEXTURE
-      };
-   int kind;  
+  public:
+    enum
+    {
+	K_INVIS = 0,
+	K_FLAT,
+	K_TEXTURE
+    };
+    int kind;
 
-   int h1, h2, tex_h;
-   // heights for the surface (h1 is above h2).
+    int h1, h2, tex_h;
+    // heights for the surface (h1 is above h2).
 
-   Img *img;
-   img_pixel_t col;  /* used if img is zero */
+    Img *img;
+    img_pixel_t col;		/* used if img is zero */
 
-   enum
-      {
-      SOLID_ABOVE = 1,
-      SOLID_BELOW = 2
-      };
-   int y_clip;
+    enum
+    {
+	SOLID_ABOVE = 1,
+	SOLID_BELOW = 2
+    };
+    int y_clip;
 
-   /* CTor */
-
-   DrawSurf () { kind = K_INVIS; img = 0; }
+    /* CTor */
 
-   void FindFlat (const wad_flat_name_t& fname, Sector *sec)
-      {
-      if (view.texturing)
-         {
-         img = view.im_ch->GetFlat (fname);
+      DrawSurf()
+    {
+	kind = K_INVIS;
+	img = 0;
+    }
 
-         if (img != 0)
-            return;
-         }
-      col = 0x70 + ((sec - Sectors) % 48);
-      }
+    void FindFlat(const wad_flat_name_t & fname, Sector * sec)
+    {
+	if (view.texturing)
+	{
+	    img = view.im_ch->GetFlat(fname);
 
-   void FindTex (const wad_tex_name_t& tname, LineDef *ld)
-      {
-      if (view.texturing)
-         {
-         img = view.im_ch->GetTex (tname);
+	    if (img != 0)
+		return;
+	}
+	col = 0x70 + ((sec - Sectors) % 48);
+    }
 
-         if (img != 0)
-            return;
-         }
-      col = 0x30 + ((ld - LineDefs) % 64);
+    void FindTex(const wad_tex_name_t & tname, LineDef * ld)
+    {
+	if (view.texturing)
+	{
+	    img = view.im_ch->GetTex(tname);
 
-      if (col >= 0x60)
-         col += 0x70;
-      }
+	    if (img != 0)
+		return;
+	}
+	col = 0x30 + ((ld - LineDefs) % 64);
+
+	if (col >= 0x60)
+	    col += 0x70;
+    }
 };
 
 
 struct DrawWall
 {
-public:
-   typedef std::vector<struct DrawWall *> vec_t;
+  public:
+    typedef std::vector < struct DrawWall *>vec_t;
 
-   Thing *th;
-   // when `th' is non-zero, this is actually a sprite, and `ld' and
-   // `sd' will be zero.  Sprites use the info in the `ceil' surface.
+    Thing *th;
+    // when `th' is non-zero, this is actually a sprite, and `ld' and
+    // `sd' will be zero.  Sprites use the info in the `ceil' surface.
 
-   LineDef *ld;
-   SideDef *sd;
-   Sector *sec;
+    LineDef *ld;
+    SideDef *sd;
+    Sector *sec;
 
-   int side;
-   // which side this wall faces (0 right, 1 left)
+    int side;
+    // which side this wall faces (0 right, 1 left)
 
-   float ang1, dang, cur_ang;
-   float base_ang;
-   // clipped angles
+    float ang1, dang, cur_ang;
+    float base_ang;
+    // clipped angles
 
-   float dist, t_dist;
-   float normal;
-   // line constants
+    float dist, t_dist;
+    float normal;
+    // line constants
 
-   double iz1, diz, cur_iz; 
-   double mid_iz;
-   // distance values (inverted, so they can be lerped)
+    double iz1, diz, cur_iz;
+    double mid_iz;
+    // distance values (inverted, so they can be lerped)
 
-   float spr_tx1;
-   // translate coord, for sprite
+    float spr_tx1;
+    // translate coord, for sprite
+
+    int sx1, sx2;
+    // screen X coordinates
 
-   int sx1, sx2;
-   // screen X coordinates
- 
-   int oy1, oy2;
-   // for sprites, the remembered open space to clip to
+    int oy1, oy2;
+    // for sprites, the remembered open space to clip to
+
+    /* surfaces */
 
-   /* surfaces */
-   
-   DrawSurf ceil;
-   DrawSurf upper;
-   DrawSurf lower;
-   DrawSurf floor;
+    DrawSurf ceil;
+    DrawSurf upper;
+    DrawSurf lower;
+    DrawSurf floor;
 
-   static const double IZ_EPSILON = 0.000001;
+    static const double IZ_EPSILON = 0.000001;
 
-   /* PREDICATES */
+    /* PREDICATES */
 
-   struct MidDistCmp
-      {
-      inline bool operator() (const DrawWall * A, const DrawWall * B) const
-         {
-         return A->mid_iz > B->mid_iz;
-         }
-      };
+    struct MidDistCmp
+    {
+	inline bool operator() (const DrawWall * A, const DrawWall * B) const
+	{
+	    return A->mid_iz > B->mid_iz;
+	}
+    };
 
-   struct DistCmp
-      {
-      inline bool operator() (const DrawWall * A, const DrawWall * B) const
-         {
-         if (fabs (A->cur_iz - B->cur_iz) < IZ_EPSILON)
-            return A->diz > B->diz;
+    struct DistCmp
+    {
+	inline bool operator() (const DrawWall * A, const DrawWall * B) const
+	{
+	    if (fabs(A->cur_iz - B->cur_iz) < IZ_EPSILON)
+		return A->diz > B->diz;
 
-         return A->cur_iz > B->cur_iz;
-         }
-      };
+	    return A->cur_iz > B->cur_iz;
+	}
+    };
 
-   struct SX1Cmp
-      {
-      inline bool operator() (const DrawWall * A, const DrawWall * B) const
-         {
-         return A->sx1 < B->sx1;
-         }
+    struct SX1Cmp
+    {
+	inline bool operator() (const DrawWall * A, const DrawWall * B) const
+	{
+	    return A->sx1 < B->sx1;
+	}
 
-      inline bool operator() (const DrawWall * A, int x) const
-         {
-         return A->sx1 < x;
-         }
+	inline bool operator() (const DrawWall * A, int x) const
+	{
+	    return A->sx1 < x;
+	}
 
-      inline bool operator() (int x, const DrawWall * A) const
-         {
-         return x < A->sx1;
-         }
-      };
+	inline bool operator() (int x, const DrawWall * A) const
+	{
+	    return x < A->sx1;
+	}
+    };
+
+    struct SX2Less
+    {
+	int x;
 
-   struct SX2Less
-      {
-      int x;
-
-      SX2Less (int _x) : x (_x) { }
+	  SX2Less(int _x):x(_x)
+	{
+	}
 
-      inline bool operator() (const DrawWall * A) const
-         {
-         return A->sx2 < x;
-         }
-      };
+	inline bool operator() (const DrawWall * A) const
+	{
+	    return A->sx2 < x;
+	}
+    };
 
-   /* methods */
+    /* methods */
 
-   void ComputeWallSurface ()
-      {
-      Sector *front = sec;
-      Sector *back  = 0;
+    void ComputeWallSurface()
+    {
+	Sector *front = sec;
+	Sector *back = 0;
 
-      if (is_obj (side ? ld->sidedef1 : ld->sidedef2))
-         {
-         SideDef *bsd = SideDefs + (side ? ld->sidedef1 : ld->sidedef2);
+	if (is_obj(side ? ld->sidedef1 : ld->sidedef2))
+	{
+	    SideDef *bsd = SideDefs + (side ? ld->sidedef1 : ld->sidedef2);
 
-         if (is_obj (bsd->sector))
-            back = Sectors + bsd->sector;
-         }
+	    if (is_obj(bsd->sector))
+		back = Sectors + bsd->sector;
+	}
 
-      bool sky_upper = back && is_sky (front->ceilt) && is_sky (back->ceilt);
+	bool sky_upper = back && is_sky(front->ceilt) && is_sky(back->ceilt);
 
-      if ((front->ceilh > view.z || is_sky (front->ceilt)) && ! sky_upper) 
-         {
-         ceil.kind = DrawSurf::K_FLAT;
-         ceil.h1 = +99999;
-         ceil.h2 = front->ceilh;
-         ceil.tex_h = ceil.h2;
-         ceil.y_clip = DrawSurf::SOLID_ABOVE;
+	if ((front->ceilh > view.z || is_sky(front->ceilt)) && !sky_upper)
+	{
+	    ceil.kind = DrawSurf::K_FLAT;
+	    ceil.h1 = +99999;
+	    ceil.h2 = front->ceilh;
+	    ceil.tex_h = ceil.h2;
+	    ceil.y_clip = DrawSurf::SOLID_ABOVE;
 
-         if (is_sky (front->ceilt))
-            ceil.col = sky_colour;
-         else
-            ceil.FindFlat (front->ceilt, front);
-         }
+	    if (is_sky(front->ceilt))
+		ceil.col = sky_colour;
+	    else
+		ceil.FindFlat(front->ceilt, front);
+	}
 
-      if (front->floorh < view.z)
-         {
-         floor.kind = DrawSurf::K_FLAT;
-         floor.h1 = front->floorh;
-         floor.h2 = -99999;
-         floor.tex_h = floor.h1;
-         floor.y_clip = DrawSurf::SOLID_BELOW;
+	if (front->floorh < view.z)
+	{
+	    floor.kind = DrawSurf::K_FLAT;
+	    floor.h1 = front->floorh;
+	    floor.h2 = -99999;
+	    floor.tex_h = floor.h1;
+	    floor.y_clip = DrawSurf::SOLID_BELOW;
 
-         if (is_sky (front->floort))
-            floor.col = sky_colour;
-         else
-            floor.FindFlat (front->floort, front);
-         }
+	    if (is_sky(front->floort))
+		floor.col = sky_colour;
+	    else
+		floor.FindFlat(front->floort, front);
+	}
 
-      if (! back)
-         {
-         /* ONE-sided line */
+	if (!back)
+	{
+	    /* ONE-sided line */
 
-         lower.kind = DrawSurf::K_TEXTURE;
-         lower.h1 = front->ceilh;
-         lower.h2 = front->floorh;
-         lower.y_clip = DrawSurf::SOLID_ABOVE | DrawSurf::SOLID_BELOW;
+	    lower.kind = DrawSurf::K_TEXTURE;
+	    lower.h1 = front->ceilh;
+	    lower.h2 = front->floorh;
+	    lower.y_clip = DrawSurf::SOLID_ABOVE | DrawSurf::SOLID_BELOW;
 
-         lower.FindTex (sd->tex3, ld);
+	    lower.FindTex(sd->tex3, ld);
 
-         if (lower.img && (ld->flags & ML_LOWER_UNPEGGED))
-            lower.tex_h = lower.h2 + lower.img->height ();
-         else
-            lower.tex_h = lower.h1;
-         }
-      else
-         {
-         /* TWO-sided line */
+	    if (lower.img && (ld->flags & ML_LOWER_UNPEGGED))
+		lower.tex_h = lower.h2 + lower.img->height();
+	    else
+		lower.tex_h = lower.h1;
+	}
+	else
+	{
+	    /* TWO-sided line */
 
-         if (back->ceilh < front->ceilh && ! sky_upper)
-            {
-            upper.kind = DrawSurf::K_TEXTURE;
-            upper.h1 = front->ceilh;
-            upper.h2 = back->ceilh;
-            upper.tex_h = upper.h1;
-            upper.y_clip = DrawSurf::SOLID_ABOVE;
+	    if (back->ceilh < front->ceilh && !sky_upper)
+	    {
+		upper.kind = DrawSurf::K_TEXTURE;
+		upper.h1 = front->ceilh;
+		upper.h2 = back->ceilh;
+		upper.tex_h = upper.h1;
+		upper.y_clip = DrawSurf::SOLID_ABOVE;
 
-            upper.FindTex (sd->tex1, ld);
+		upper.FindTex(sd->tex1, ld);
 
-            if (upper.img && ! (ld->flags & ML_UPPER_UNPEGGED))
-               upper.tex_h = upper.h2 + upper.img->height ();
-            else
-               upper.tex_h = upper.h1;
-            }
+		if (upper.img && !(ld->flags & ML_UPPER_UNPEGGED))
+		    upper.tex_h = upper.h2 + upper.img->height();
+		else
+		    upper.tex_h = upper.h1;
+	    }
 
-         if (back->floorh > front->floorh)
-            {
-            lower.kind = DrawSurf::K_TEXTURE;
-            lower.h1 = back->floorh;
-            lower.h2 = front->floorh;
-            lower.y_clip = DrawSurf::SOLID_BELOW;
+	    if (back->floorh > front->floorh)
+	    {
+		lower.kind = DrawSurf::K_TEXTURE;
+		lower.h1 = back->floorh;
+		lower.h2 = front->floorh;
+		lower.y_clip = DrawSurf::SOLID_BELOW;
 
-            lower.FindTex (sd->tex2, ld);
+		lower.FindTex(sd->tex2, ld);
 
-            if (ld->flags & ML_LOWER_UNPEGGED)
-               lower.tex_h = front->ceilh;
-            else
-               lower.tex_h = lower.h1;
-            }
-         }
-      }
+		if (ld->flags & ML_LOWER_UNPEGGED)
+		    lower.tex_h = front->ceilh;
+		else
+		    lower.tex_h = lower.h1;
+	    }
+	}
+    }
 };
 
 
 struct RendInfo
 {
-public:
-   DrawWall::vec_t walls;
-   // complete set of walls/sprites to draw.
+  public:
+    DrawWall::vec_t walls;
+    // complete set of walls/sprites to draw.
 
-   DrawWall::vec_t active;
-   // the active list.  Pointers here are always duplicates of ones in
-   // the walls list (no need to `delete' any of them).
+    DrawWall::vec_t active;
+    // the active list.  Pointers here are always duplicates of ones in
+    // the walls list (no need to `delete' any of them).
 
-   std::vector<double> depth_x;  
-   // inverse distances over X range, 0 when empty.
+    std::vector < double >depth_x;
+    // inverse distances over X range, 0 when empty.
 
-   int open_y1;
-   int open_y2;
+    int open_y1;
+    int open_y2;
 
-   static const double Y_SLOPE = 1.70;
+    static const double Y_SLOPE = 1.70;
 
-   static void DeleteWall (DrawWall *P)
-      {
-      delete P;
-      }
+    static void DeleteWall(DrawWall * P)
+    {
+	delete P;
+    }
+
+     ~RendInfo()
+    {
+	std::for_each(walls.begin(), walls.end(), DeleteWall);
 
-   ~RendInfo ()
-      {
-      std::for_each (walls.begin (), walls.end (), DeleteWall);
-      
-      walls.clear ();
-      active.clear ();
-      }
+	walls.clear();
+	active.clear();
+    }
+
+    void InitDepthBuf(int width)
+    {
+	depth_x.resize(width);
 
-   void InitDepthBuf (int width)
-      {
-      depth_x.resize (width);
+	std::fill_n(depth_x.begin(), width, 0);
+    }
 
-      std::fill_n (depth_x.begin (), width, 0);
-      }
-
-   static inline float PointToAngle (float x, float y)
-      {
-      if (-0.01 < x && x < 0.01)
-         return (y > 0) ? HALFPI : (3 * HALFPI);
+    static inline float PointToAngle(float x, float y)
+    {
+	if (-0.01 < x && x < 0.01)
+	    return (y > 0) ? HALFPI : (3 * HALFPI);
 
-      float angle = atan2(y, x);
+	float angle = atan2(y, x);
 
-      if (angle < 0)
-         angle += TWOPI;
+	if (angle < 0)
+	    angle += TWOPI;
 
-      return angle;
-      }
+	return angle;
+    }
 
-   static inline int AngleToX (float ang)
-      {
-      float t = tan (HALFPI - ang);
+    static inline int AngleToX(float ang)
+    {
+	float t = tan(HALFPI - ang);
 
-      int x = int (view.sw * t);
+	int x = int (view.sw * t);
 
-      x = (view.sw + x) / 2;
+	x = (view.sw + x) / 2;
 
-      if (x < 0)
-         x = 0;
-      else if (x > view.sw)
-         x = view.sw;
+	if (x < 0)
+	    x = 0;
+	else if (x > view.sw)
+	    x = view.sw;
 
-      return x;
-      }
+	return x;
+    }
 
-   static inline float XToAngle (int x)
-      {
-      x = x * 2 - view.sw;
+    static inline float XToAngle(int x)
+    {
+	x = x * 2 - view.sw;
 
-      float ang = HALFPI + atan (x / float (view.sw));
+	float ang = HALFPI + atan(x / float (view.sw));
 
-      if (ang < 0)
-         ang = 0;
-      else if (ang > ONEPI)
-         ang = ONEPI;
+	if (ang < 0)
+	    ang = 0;
+	else if (ang > ONEPI)
+	    ang = ONEPI;
 
-      return ang;
-      }
+	return ang;
+    }
 
-   static inline int DeltaToX (double iz, float tx)
-      {
-      int x = int (view.sw * tx * iz);
+    static inline int DeltaToX(double iz, float tx)
+    {
+	int x = int (view.sw * tx * iz);
 
-      x = (x + view.sw) / 2;
+	x = (x + view.sw) / 2;
 
-      return x;
-      }
+	return x;
+    }
 
-   static inline float XToDelta (int x, double iz)
-      {
-      x = x * 2 - view.sw;
+    static inline float XToDelta(int x, double iz)
+    {
+	x = x * 2 - view.sw;
 
-      float tx = x / iz / view.sw;
+	float tx = x / iz / view.sw;
 
-      return tx;
-      }
+	return tx;
+    }
 
-   static inline int DistToY (double iz, int sec_h)
-      {
-      if (sec_h > 32770)
-         return -9999;
+    static inline int DistToY(double iz, int sec_h)
+    {
+	if (sec_h > 32770)
+	    return -9999;
 
-      if (sec_h < -32770)
-         return +9999;
+	if (sec_h < -32770)
+	    return +9999;
 
-      sec_h -= view.z;
+	sec_h -= view.z;
 
-      int y = int (view.sh * sec_h * iz * Y_SLOPE);
+	int y = int (view.sh * sec_h * iz * Y_SLOPE);
 
-      y = (view.sh - y) / 2;
+	y = (view.sh - y) / 2;
 
-      return y;
-      }
+	return y;
+    }
 
-   static inline float YToDist (int y, int sec_h)
-      {
-      sec_h -= view.z;
+    static inline float YToDist(int y, int sec_h)
+    {
+	sec_h -= view.z;
 
-      y = y * 2 - view.sh;
+	y = y * 2 - view.sh;
 
-      if (y == 0)
-         return 999999;
+	if (y == 0)
+	    return 999999;
 
-      return view.sh * sec_h * Y_SLOPE / y;
-      }
+	return view.sh * sec_h * Y_SLOPE / y;
+    }
 
-   static inline float YToSecH (int y, double iz)
-      {
-      y = y * 2 - view.sh;
+    static inline float YToSecH(int y, double iz)
+    {
+	y = y * 2 - view.sh;
 
-      return view.z - (float (y) / view.sh / iz / Y_SLOPE);
-      }
+	return view.z - (float (y) / view.sh / iz / Y_SLOPE);
+    }
 
-   void AddLine (int linenum)
-      {
-      LineDef *ld = LineDefs + linenum;
+    void AddLine(int linenum)
+    {
+	LineDef *ld = LineDefs + linenum;
 
-      if (! is_obj (ld->start) || ! is_obj (ld->end))
-         return;
+	if (!is_obj(ld->start) || !is_obj(ld->end))
+	    return;
 
-      float x1 = Vertices[ld->start].x - view.x;
-      float y1 = Vertices[ld->start].y - view.y;
-      float x2 = Vertices[ld->end].x - view.x;
-      float y2 = Vertices[ld->end].y - view.y;
+	float x1 = Vertices[ld->start].x - view.x;
+	float y1 = Vertices[ld->start].y - view.y;
+	float x2 = Vertices[ld->end].x - view.x;
+	float y2 = Vertices[ld->end].y - view.y;
 
-      float tx1 = x1 * view.Sin - y1 * view.Cos;
-      float ty1 = x1 * view.Cos + y1 * view.Sin;
-      float tx2 = x2 * view.Sin - y2 * view.Cos;
-      float ty2 = x2 * view.Cos + y2 * view.Sin;
+	float tx1 = x1 * view.Sin - y1 * view.Cos;
+	float ty1 = x1 * view.Cos + y1 * view.Sin;
+	float tx2 = x2 * view.Sin - y2 * view.Cos;
+	float ty2 = x2 * view.Cos + y2 * view.Sin;
 
-      // reject line if complete behind viewplane
-      if (ty1 <= 0 && ty2 <= 0)
-         return;
+	// reject line if complete behind viewplane
+	if (ty1 <= 0 && ty2 <= 0)
+	    return;
 
-      float angle1 = PointToAngle (tx1, ty1);
-      float angle2 = PointToAngle (tx2, ty2);
-      float span = angle1 - angle2;
+	float angle1 = PointToAngle(tx1, ty1);
+	float angle2 = PointToAngle(tx2, ty2);
+	float span = angle1 - angle2;
 
-      if (span < 0)
-         span += TWOPI;
+	if (span < 0)
+	    span += TWOPI;
 
-      int side = 0;
-      SideDef *sd;
+	int side = 0;
+	SideDef *sd;
 
-      if (span >= ONEPI)
-         side = 1;
+	if (span >= ONEPI)
+	    side = 1;
 
-      // ignore the line when there is no facing sidedef
-      if (! is_obj (side ? ld->sidedef2 : ld->sidedef1))
-         return;
+	// ignore the line when there is no facing sidedef
+	if (!is_obj(side ? ld->sidedef2 : ld->sidedef1))
+	    return;
 
-      sd = SideDefs + (side ? ld->sidedef2 : ld->sidedef1);
+	sd = SideDefs + (side ? ld->sidedef2 : ld->sidedef1);
 
-      if (! is_obj (sd->sector))
-         return;
+	if (!is_obj(sd->sector))
+	    return;
 
-      if (side == 1)
-         {
-         float tmp = angle1;
-         angle1 = angle2;
-         angle2 = tmp;
-         }
+	if (side == 1)
+	{
+	    float tmp = angle1;
+	    angle1 = angle2;
+	    angle2 = tmp;
+	}
 
-      // clip angles to view volume
+	// clip angles to view volume
 
-      float base_ang = angle1;
+	float base_ang = angle1;
 
-      float leftclip  = (3 * ONEPI / 4);
-      float rightclip = ONEPI / 4;
+	float leftclip = (3 * ONEPI / 4);
+	float rightclip = ONEPI / 4;
 
-      float tspan1 = angle1 - rightclip;
-      float tspan2 = leftclip - angle2;
+	float tspan1 = angle1 - rightclip;
+	float tspan2 = leftclip - angle2;
 
-      if (tspan1 < 0) tspan1 += TWOPI;
-      if (tspan2 < 0) tspan2 += TWOPI;
-
-      if (tspan1 > HALFPI)
-         {
-         // Totally off the left edge?
-         if (tspan2 >= ONEPI)
-            return;
+	if (tspan1 < 0)
+	    tspan1 += TWOPI;
+	if (tspan2 < 0)
+	    tspan2 += TWOPI;
 
-         angle1 = leftclip;
-         }
+	if (tspan1 > HALFPI)
+	{
+	    // Totally off the left edge?
+	    if (tspan2 >= ONEPI)
+		return;
 
-      if (tspan2 > HALFPI)
-         {
-         // Totally off the left edge?
-         if (tspan1 >= ONEPI)
-            return;
+	    angle1 = leftclip;
+	}
 
-         angle2 = rightclip;
-         }
+	if (tspan2 > HALFPI)
+	{
+	    // Totally off the left edge?
+	    if (tspan1 >= ONEPI)
+		return;
 
-      // convert angles to on-screen X positions
-      int sx1 = AngleToX (angle1);
-      int sx2 = AngleToX (angle2) - 1;
+	    angle2 = rightclip;
+	}
 
-      if (sx1 > sx2)
-         return;
+	// convert angles to on-screen X positions
+	int sx1 = AngleToX(angle1);
+	int sx2 = AngleToX(angle2) - 1;
+
+	if (sx1 > sx2)
+	    return;
 
-      // compute distance from eye to wall
-      float wdx = x2 - x1;
-      float wdy = y2 - y1;
+	// compute distance from eye to wall
+	float wdx = x2 - x1;
+	float wdy = y2 - y1;
 
-      float wlen = sqrt (wdx * wdx + wdy * wdy);
-      float dist = fabs ((y1 * wdx / wlen) - (x1 * wdy / wlen));
+	float wlen = sqrt(wdx * wdx + wdy * wdy);
+	float dist = fabs((y1 * wdx / wlen) - (x1 * wdy / wlen));
 
-      if (dist < 0.01)
-         return;
-
-      // compute normal of wall (translated coords)
-      float normal;
+	if (dist < 0.01)
+	    return;
 
-      if (side == 1)
-         normal = PointToAngle (ty2 - ty1, tx1 - tx2);
-      else
-         normal = PointToAngle (ty1 - ty2, tx2 - tx1);
+	// compute normal of wall (translated coords)
+	float normal;
 
-      // compute inverse distances
-      double iz1 = cos (normal - angle1) / dist / cos (HALFPI - angle1);
-      double iz2 = cos (normal - angle2) / dist / cos (HALFPI - angle2);
+	if (side == 1)
+	    normal = PointToAngle(ty2 - ty1, tx1 - tx2);
+	else
+	    normal = PointToAngle(ty1 - ty2, tx2 - tx1);
 
-      double diz = (iz2 - iz1) / y_max (1, sx2 - sx1);
-
-      // create drawwall structure
+	// compute inverse distances
+	double iz1 = cos(normal - angle1) / dist / cos(HALFPI - angle1);
+	double iz2 = cos(normal - angle2) / dist / cos(HALFPI - angle2);
 
-      DrawWall *dw = new DrawWall;
+	double diz = (iz2 - iz1) / y_max(1, sx2 - sx1);
+
+	// create drawwall structure
+
+	DrawWall *dw = new DrawWall;
 
-      dw->th = 0;
-      dw->ld = ld;
-      dw->sd = sd;
-      dw->sec = Sectors + sd->sector;
+	dw->th = 0;
+	dw->ld = ld;
+	dw->sd = sd;
+	dw->sec = Sectors + sd->sector;
 
-      dw->side = side;
-
-      dw->base_ang = base_ang;
-      dw->ang1 = angle1;
-      dw->dang = (angle2 - angle1) / y_max (1, sx2 - sx1);
+	dw->side = side;
 
-      dw->dist = dist;
-      dw->normal = normal;
-      dw->t_dist = tan (base_ang - normal) * dist;
+	dw->base_ang = base_ang;
+	dw->ang1 = angle1;
+	dw->dang = (angle2 - angle1) / y_max(1, sx2 - sx1);
 
-      dw->iz1 = iz1;
-      dw->diz = diz;
-      dw->mid_iz = iz1 + (sx2 - sx1 + 1) * diz / 2;
-
-      dw->sx1 = sx1;  dw->sx2 = sx2;
+	dw->dist = dist;
+	dw->normal = normal;
+	dw->t_dist = tan(base_ang - normal) * dist;
 
-      walls.push_back (dw);
-      }
+	dw->iz1 = iz1;
+	dw->diz = diz;
+	dw->mid_iz = iz1 + (sx2 - sx1 + 1) * diz / 2;
+
+	dw->sx1 = sx1;
+	dw->sx2 = sx2;
 
-   void AddThing (int thingnum)
-      {
-      Thing *th = Things + thingnum;
+	walls.push_back(dw);
+    }
 
-      float x = th->xpos - view.x;
-      float y = th->ypos - view.y;
+    void AddThing(int thingnum)
+    {
+	Thing *th = Things + thingnum;
 
-      float tx = x * view.Sin - y * view.Cos;
-      float ty = x * view.Cos + y * view.Sin;
+	float x = th->xpos - view.x;
+	float y = th->ypos - view.y;
 
-      // reject sprite if complete behind viewplane
-      if (ty < 4)
-         return;
+	float tx = x * view.Sin - y * view.Cos;
+	float ty = x * view.Cos + y * view.Sin;
 
-      Img *sprite = view.im_ch->GetSprite (th->type);
-      if (! sprite)
-         return;
+	// reject sprite if complete behind viewplane
+	if (ty < 4)
+	    return;
 
-      float tx1 = tx - sprite->width () / 2.0;
-      float tx2 = tx + sprite->width () / 2.0;
-
-      double iz = 1 / ty;
+	Img *sprite = view.im_ch->GetSprite(th->type);
+	if (!sprite)
+	    return;
 
-      int sx1 = DeltaToX (iz, tx1);
-      int sx2 = DeltaToX (iz, tx2) - 1;
+	float tx1 = tx - sprite->width() / 2.0;
+	float tx2 = tx + sprite->width() / 2.0;
 
-      if (sx1 < 0)
-         sx1 = 0;
+	double iz = 1 / ty;
+
+	int sx1 = DeltaToX(iz, tx1);
+	int sx2 = DeltaToX(iz, tx2) - 1;
 
-      if (sx2 >= view.sw)
-         sx2 = view.sw - 1;
+	if (sx1 < 0)
+	    sx1 = 0;
 
-      if (sx1 > sx2)
-         return;
+	if (sx2 >= view.sw)
+	    sx2 = view.sw - 1;
 
-      int h2 = view.thing_floors[thingnum];
-      int h1 = h2 + sprite->height ();
-
-      // create drawwall structure
+	if (sx1 > sx2)
+	    return;
 
-      DrawWall *dw = new DrawWall;
+	int h2 = view.thing_floors[thingnum];
+	int h1 = h2 + sprite->height();
+
+	// create drawwall structure
+
+	DrawWall *dw = new DrawWall;
 
-      dw->th = th;
-      dw->ld = 0;
-      dw->sd = 0;
-      dw->sec = 0;
+	dw->th = th;
+	dw->ld = 0;
+	dw->sd = 0;
+	dw->sec = 0;
 
-      dw->spr_tx1 = tx1;
-
-      dw->ang1 = dw->dang = 0;
+	dw->spr_tx1 = tx1;
 
-      dw->iz1 = dw->mid_iz = iz;
-      dw->diz = 0;
+	dw->ang1 = dw->dang = 0;
 
-      dw->sx1 = sx1;  dw->sx2 = sx2;
+	dw->iz1 = dw->mid_iz = iz;
+	dw->diz = 0;
 
-      dw->ceil.img = sprite;
-      dw->ceil.h1  = h1;
-      dw->ceil.h2  = h2;
+	dw->sx1 = sx1;
+	dw->sx2 = sx2;
 
-      walls.push_back (dw);
-      }
+	dw->ceil.img = sprite;
+	dw->ceil.h1 = h1;
+	dw->ceil.h2 = h2;
 
-   void ComputeSurfaces ()
-      {
-      DrawWall::vec_t::iterator S;
+	walls.push_back(dw);
+    }
 
-      for (S = walls.begin (); S != walls.end (); S++)
-         if ((*S)->ld)
-            (*S)->ComputeWallSurface ();
-      }
+    void ComputeSurfaces()
+    {
+	DrawWall::vec_t::iterator S;
 
-   void ClipSolids ()
-      {
-      // perform a rough depth sort of the walls and sprites.
+	for (S = walls.begin(); S != walls.end(); S++)
+	    if ((*S)->ld)
+		(*S)->ComputeWallSurface();
+    }
 
-      std::sort (walls.begin (), walls.end (), DrawWall::MidDistCmp ());
-
-      // go forwards, from closest to furthest away
+    void ClipSolids()
+    {
+	// perform a rough depth sort of the walls and sprites.
 
-      DrawWall::vec_t::iterator S;
+	std::sort(walls.begin(), walls.end(), DrawWall::MidDistCmp());
 
-      for (S = walls.begin (); S != walls.end (); S++)
-         {
-         DrawWall *dw = (*S);
+	// go forwards, from closest to furthest away
+
+	DrawWall::vec_t::iterator S;
 
-         if (! dw)
-            continue;
+	for (S = walls.begin(); S != walls.end(); S++)
+	{
+	    DrawWall *dw = (*S);
 
-         int one_sided = dw->ld && ! is_obj (dw->ld->sidedef2);
-         int vis_count = dw->sx2 - dw->sx1 + 1;
+	    if (!dw)
+		continue;
 
-         for (int x = dw->sx1; x <= dw->sx2; x++)
-            {
-            double iz = dw->iz1 + (dw->diz * (x - dw->sx1));
+	    int one_sided = dw->ld && !is_obj(dw->ld->sidedef2);
+	    int vis_count = dw->sx2 - dw->sx1 + 1;
 
-            if (iz < depth_x[x])
-               vis_count--;
-            else if (one_sided)
-               depth_x[x] = iz;
-            }
+	    for (int x = dw->sx1; x <= dw->sx2; x++)
+	    {
+		double iz = dw->iz1 + (dw->diz * (x - dw->sx1));
+
+		if (iz < depth_x[x])
+		    vis_count--;
+		else if (one_sided)
+		    depth_x[x] = iz;
+	    }
 
-         if (vis_count == 0)
-            {
-            delete dw;
-            (*S) = 0;
-            }
-         }
+	    if (vis_count == 0)
+	    {
+		delete dw;
+		(*S) = 0;
+	    }
+	}
 
-      // remove null pointers
+	// remove null pointers
 
-      S = std::remove (walls.begin (), walls.end (), (DrawWall *) 0);
-
-      walls.erase (S, walls.end ());
-      }
+	S = std::remove(walls.begin(), walls.end(), (DrawWall *) 0);
 
-   void RenderFlatColumn (DrawWall *dw, DrawSurf& surf,
-         int x, int y1, int y2)
-      {
-      img_pixel_t *buf = view.screen->wbuf ();
-      img_pixel_t *wbuf = surf.img->wbuf ();
+	walls.erase(S, walls.end());
+    }
 
-      int tw = surf.img->width ();
-      int th = surf.img->height ();
+    void RenderFlatColumn(DrawWall * dw, DrawSurf & surf,
+			  int x, int y1, int y2)
+    {
+	img_pixel_t *buf = view.screen->wbuf();
+	img_pixel_t *wbuf = surf.img->wbuf();
 
-      float ang = XToAngle (x);
-      float modv = cos (ang - HALFPI);
-
-      float t_cos = cos (ONEPI + -view.angle + ang) / modv;
-      float t_sin = sin (ONEPI + -view.angle + ang) / modv;
+	int tw = surf.img->width();
+	int th = surf.img->height();
 
-      buf += x + y1 * view.sw;
+	float ang = XToAngle(x);
+	float modv = cos(ang - HALFPI);
 
-      for (; y1 <= y2; y1++, buf += view.sw)
-         {
-         float dist = YToDist (y1, surf.tex_h);
+	float t_cos = cos(ONEPI + -view.angle + ang) / modv;
+	float t_sin = sin(ONEPI + -view.angle + ang) / modv;
+
+	buf += x + y1 * view.sw;
 
-         int tx = int ( view.x + t_sin * dist) & (tw - 1);
-         int ty = int (-view.y - t_cos * dist) & (th - 1);
+	for (; y1 <= y2; y1++, buf += view.sw)
+	{
+	    float dist = YToDist(y1, surf.tex_h);
 
-         *buf = wbuf[ty * tw + tx];
-         }
-      }
+	    int tx = int (view.x + t_sin * dist) & (tw - 1);
+	    int ty = int (-view.y - t_cos * dist) & (th - 1);
 
-   void RenderTexColumn (DrawWall *dw, DrawSurf& surf,
-         int x, int y1, int y2)
-      {
-      img_pixel_t *buf = view.screen->wbuf ();
-      img_pixel_t *wbuf = surf.img->wbuf ();
+	    *buf = wbuf[ty * tw + tx];
+	}
+    }
 
-      int tw = surf.img->width ();
-      int th = surf.img->height ();
-
-      /* compute texture X coord */
+    void RenderTexColumn(DrawWall * dw, DrawSurf & surf,
+			 int x, int y1, int y2)
+    {
+	img_pixel_t *buf = view.screen->wbuf();
+	img_pixel_t *wbuf = surf.img->wbuf();
 
-      int tx = int (dw->t_dist - tan (dw->cur_ang - dw->normal) * dw->dist);
-
-      tx = (dw->sd->xoff + tx) & (tw - 1);
+	int tw = surf.img->width();
+	int th = surf.img->height();
 
-      /* compute texture Y coords */
+	/* compute texture X coord */
 
-      float base_h = surf.tex_h + dw->sd->yoff;
+	int tx = int (dw->t_dist - tan(dw->cur_ang - dw->normal) * dw->dist);
+
+	tx = (dw->sd->xoff + tx) & (tw - 1);
 
-      float h1 = base_h - YToSecH (y1, dw->cur_iz);
-      float dh = base_h - YToSecH (y2, dw->cur_iz);
+	/* compute texture Y coords */
+
+	float base_h = surf.tex_h + dw->sd->yoff;
 
-      dh = (dh - h1) / y_max (1, y2 - y1);
-       
-      buf  += x + y1 * view.sw;
-      wbuf += tx;
+	float h1 = base_h - YToSecH(y1, dw->cur_iz);
+	float dh = base_h - YToSecH(y2, dw->cur_iz);
+
+	dh = (dh - h1) / y_max(1, y2 - y1);
 
-      for (; y1 <= y2; y1++, h1 += dh, buf += view.sw)
-         {
-         int ty = int (h1) % th;
+	buf += x + y1 * view.sw;
+	wbuf += tx;
 
-         // handle negative values (use % twice)
-         ty = (ty + th) % th;
+	for (; y1 <= y2; y1++, h1 += dh, buf += view.sw)
+	{
+	    int ty = int (h1) % th;
 
-         *buf = wbuf[ty * tw];
-         }
-      }
+	    // handle negative values (use % twice)
+	    ty = (ty + th) % th;
 
-   void RenderSolidColumn (DrawWall *w, DrawSurf& surf,
-         int x, int y1, int y2)
-      {
-      img_pixel_t *buf = view.screen->wbuf ();
+	    *buf = wbuf[ty * tw];
+	}
+    }
+
+    void RenderSolidColumn(DrawWall * w, DrawSurf & surf,
+			   int x, int y1, int y2)
+    {
+	img_pixel_t *buf = view.screen->wbuf();
+
+	buf += x + y1 * view.sw;
 
-      buf += x + y1 * view.sw;
-       
-      for (; y1 <= y2; y1++, buf += view.sw)
-         {
-         *buf = surf.col;
-         }
-      }
+	for (; y1 <= y2; y1++, buf += view.sw)
+	{
+	    *buf = surf.col;
+	}
+    }
 
-   inline void RenderWallSurface (DrawWall *dw, DrawSurf& surf, 
-         int x)
-      {
-      if (surf.kind == DrawSurf::K_INVIS)
-         return;
+    inline void RenderWallSurface(DrawWall * dw, DrawSurf & surf, int x)
+    {
+	if (surf.kind == DrawSurf::K_INVIS)
+	    return;
 
-      int y1 = DistToY (dw->cur_iz, surf.h1);
-      int y2 = DistToY (dw->cur_iz, surf.h2) - 1;
-
-      if (y1 < open_y1)
-         y1 = open_y1;
+	int y1 = DistToY(dw->cur_iz, surf.h1);
+	int y2 = DistToY(dw->cur_iz, surf.h2) - 1;
 
-      if (y2 > open_y2)
-         y2 = open_y2;
+	if (y1 < open_y1)
+	    y1 = open_y1;
 
-      if (y1 > y2)
-         return;
+	if (y2 > open_y2)
+	    y2 = open_y2;
 
-      /* clip the open region */
+	if (y1 > y2)
+	    return;
 
-      if (surf.y_clip & DrawSurf::SOLID_ABOVE)
-         if (y2 > open_y1)
-            open_y1 = y2;
+	/* clip the open region */
+
+	if (surf.y_clip & DrawSurf::SOLID_ABOVE)
+	    if (y2 > open_y1)
+		open_y1 = y2;
 
-      if (surf.y_clip & DrawSurf::SOLID_BELOW)
-         if (y1 < open_y2)
-            open_y2 = y1;
+	if (surf.y_clip & DrawSurf::SOLID_BELOW)
+	    if (y1 < open_y2)
+		open_y2 = y1;
 
-      /* fill pixels */
+	/* fill pixels */
 
-      if (! surf.img)
-         {
-         RenderSolidColumn (dw, surf, x, y1, y2);
-         }
-      else switch (surf.kind)
-         {
-         case DrawSurf::K_FLAT:
-            RenderFlatColumn (dw, surf, x, y1, y2);
-            break;
+	if (!surf.img)
+	{
+	    RenderSolidColumn(dw, surf, x, y1, y2);
+	}
+	else
+	    switch (surf.kind)
+	    {
+	    case DrawSurf::K_FLAT:
+		RenderFlatColumn(dw, surf, x, y1, y2);
+		break;
 
-         case DrawSurf::K_TEXTURE:
-            RenderTexColumn  (dw, surf, x, y1, y2);
-            break;
-         }
-      }
+	    case DrawSurf::K_TEXTURE:
+		RenderTexColumn(dw, surf, x, y1, y2);
+		break;
+	    }
+    }
 
-   inline void RenderSprite (DrawWall *dw, int x)
-      {
-      int y1 = DistToY (dw->cur_iz, dw->ceil.h1);
-      int y2 = DistToY (dw->cur_iz, dw->ceil.h2) - 1;
+    inline void RenderSprite(DrawWall * dw, int x)
+    {
+	int y1 = DistToY(dw->cur_iz, dw->ceil.h1);
+	int y2 = DistToY(dw->cur_iz, dw->ceil.h2) - 1;
 
-      if (y1 < dw->oy1)
-         y1 = dw->oy1;
-
-      if (y2 > dw->oy2)
-         y2 = dw->oy2;
+	if (y1 < dw->oy1)
+	    y1 = dw->oy1;
 
-      if (y1 > y2)
-         return;
+	if (y2 > dw->oy2)
+	    y2 = dw->oy2;
 
-      /* fill pixels */
+	if (y1 > y2)
+	    return;
 
-      img_pixel_t *buf = view.screen->wbuf ();
-      img_pixel_t *wbuf = dw->ceil.img->wbuf ();
+	/* fill pixels */
 
-      int tw = dw->ceil.img->width ();
-      int th = dw->ceil.img->height ();
-
-      int tx = int (XToDelta (x, dw->cur_iz) - dw->spr_tx1);
+	img_pixel_t *buf = view.screen->wbuf();
+	img_pixel_t *wbuf = dw->ceil.img->wbuf();
 
-      if (tx < 0 || tx >= tw)
-         return;
+	int tw = dw->ceil.img->width();
+	int th = dw->ceil.img->height();
 
-      float h1 = dw->ceil.h1 - YToSecH (y1, dw->cur_iz);
-      float dh = dw->ceil.h1 - YToSecH (y2, dw->cur_iz);
+	int tx = int (XToDelta(x, dw->cur_iz) - dw->spr_tx1);
+
+	if (tx < 0 || tx >= tw)
+	    return;
 
-      dh = (dh - h1) / y_max (1, y2 - y1);
-       
-      buf  += x + y1 * view.sw;
-      wbuf += tx;
+	float h1 = dw->ceil.h1 - YToSecH(y1, dw->cur_iz);
+	float dh = dw->ceil.h1 - YToSecH(y2, dw->cur_iz);
 
-      for (; y1 <= y2; y1++, h1 += dh, buf += view.sw)
-         {
-         int ty = int (h1);
+	dh = (dh - h1) / y_max(1, y2 - y1);
+
+	buf += x + y1 * view.sw;
+	wbuf += tx;
 
-         if (ty < 0 || ty >= th)
-            continue;
+	for (; y1 <= y2; y1++, h1 += dh, buf += view.sw)
+	{
+	    int ty = int (h1);
 
-         img_pixel_t pix = wbuf[ty * tw];
+	    if (ty < 0 || ty >= th)
+		continue;
 
-         if (pix != IMG_TRANSP)
-            *buf = pix;
-         }
-      }
+	    img_pixel_t pix = wbuf[ty * tw];
 
-   void UpdateActiveList (int x)
-      {
-      DrawWall::vec_t::iterator S, E, P;
+	    if (pix != IMG_TRANSP)
+		*buf = pix;
+	}
+    }
 
-      bool changes = false;
-
-      // remove walls that have finished.
+    void UpdateActiveList(int x)
+    {
+	DrawWall::vec_t::iterator S, E, P;
 
-      S = active.begin ();
-      E = active.end ();
+	bool changes = false;
 
-      S = std::remove_if (S, E, DrawWall::SX2Less (x));
+	// remove walls that have finished.
 
-      if (S != E)
-         {
-         active.erase (S, E);
-         changes = true;
-         }
+	S = active.begin();
+	E = active.end();
+
+	S = std::remove_if(S, E, DrawWall::SX2Less(x));
 
-      // add new walls that start in this column.
+	if (S != E)
+	{
+	    active.erase(S, E);
+	    changes = true;
+	}
 
-      S = walls.begin ();
-      E = walls.end ();
+	// add new walls that start in this column.
 
-      S = std::lower_bound (S, E, x, DrawWall::SX1Cmp ());
-      E = std::upper_bound (S, E, x, DrawWall::SX1Cmp ());
+	S = walls.begin();
+	E = walls.end();
 
-      if (S != E)
-         changes = true;
+	S = std::lower_bound(S, E, x, DrawWall::SX1Cmp());
+	E = std::upper_bound(S, E, x, DrawWall::SX1Cmp());
 
-      for (; S != E; S++)
-         {
-         active.push_back (*S);
-         }
+	if (S != E)
+	    changes = true;
 
-      // calculate new depth values
+	for (; S != E; S++)
+	{
+	    active.push_back(*S);
+	}
 
-      S = active.begin ();
-      E = active.end ();
+	// calculate new depth values
 
-      for (P=S; (P != E); P++)
-         {
-         DrawWall *dw = (*P);
+	S = active.begin();
+	E = active.end();
 
-         dw->cur_iz = dw->iz1 + dw->diz * (x - dw->sx1);
+	for (P = S; (P != E); P++)
+	{
+	    DrawWall *dw = (*P);
 
-         if (P != S && (*(P-1))->cur_iz < dw->cur_iz)
-            changes = true;
+	    dw->cur_iz = dw->iz1 + dw->diz * (x - dw->sx1);
 
-         dw->cur_ang = dw->ang1 + dw->dang * (x - dw->sx1);
-         }
+	    if (P != S && (*(P - 1))->cur_iz < dw->cur_iz)
+		changes = true;
 
-      // if there are changes, re-sort the active list...
+	    dw->cur_ang = dw->ang1 + dw->dang * (x - dw->sx1);
+	}
+
+	// if there are changes, re-sort the active list...
 
-      if (changes)
-         {
-         std::sort (active.begin (), active.end (), DrawWall::DistCmp ());
-         }
-      }
+	if (changes)
+	{
+	    std::sort(active.begin(), active.end(), DrawWall::DistCmp());
+	}
+    }
 
-   void RenderWalls ()
-      {
-      // sort walls by their starting column, to allow binary search.
+    void RenderWalls()
+    {
+	// sort walls by their starting column, to allow binary search.
 
-      std::sort (walls.begin (), walls.end (), DrawWall::SX1Cmp ());
-
-      active.clear ();
+	std::sort(walls.begin(), walls.end(), DrawWall::SX1Cmp());
 
-      for (int x=0; x < view.sw; x++)
-         {
-         // clear vertical depth buffer
+	active.clear();
 
-         open_y1 = 0;
-         open_y2 = view.sh - 1;
+	for (int x = 0; x < view.sw; x++)
+	{
+	    // clear vertical depth buffer
 
-         UpdateActiveList (x);
+	    open_y1 = 0;
+	    open_y2 = view.sh - 1;
+
+	    UpdateActiveList(x);
 
-         // render, front to back
+	    // render, front to back
 
-         DrawWall::vec_t::iterator S, E, P;
+	    DrawWall::vec_t::iterator S, E, P;
 
-         S = active.begin ();
-         E = active.end ();
+	    S = active.begin();
+	    E = active.end();
 
-         for (P=S; P != E; P++)
-            {
-            DrawWall *dw = (*P);
+	    for (P = S; P != E; P++)
+	    {
+		DrawWall *dw = (*P);
 
-            // for things, just remember the open space
-            if (dw->th)
-               {
-               dw->oy1 = open_y1;
-               dw->oy2 = open_y2;
-               continue;
-               }
+		// for things, just remember the open space
+		if (dw->th)
+		{
+		    dw->oy1 = open_y1;
+		    dw->oy2 = open_y2;
+		    continue;
+		}
 
-            RenderWallSurface (dw, dw->ceil,  x);
-            RenderWallSurface (dw, dw->floor, x);
-            RenderWallSurface (dw, dw->upper, x);
-            RenderWallSurface (dw, dw->lower, x);
+		RenderWallSurface(dw, dw->ceil, x);
+		RenderWallSurface(dw, dw->floor, x);
+		RenderWallSurface(dw, dw->upper, x);
+		RenderWallSurface(dw, dw->lower, x);
 
-            if (open_y1 >= open_y2)
-               break;
-            }
+		if (open_y1 >= open_y2)
+		    break;
+	    }
 
-         // now render things, back to front
+	    // now render things, back to front
 
-         if (P == E)
-            P--;
+	    if (P == E)
+		P--;
 
-         for (; P != (S-1); P--)
-            {
-            DrawWall *dw = (*P);
+	    for (; P != (S - 1); P--)
+	    {
+		DrawWall *dw = (*P);
 
-            if (dw->th)
-               RenderSprite (dw, x);
-            }
-         }
-      }
+		if (dw->th)
+		    RenderSprite(dw, x);
+	    }
+	}
+    }
 
-   void DoRender3D ()
-      {
-      view.ClearScreen ();
+    void DoRender3D()
+    {
+	view.ClearScreen();
 
-      InitDepthBuf (view.sw);
+	InitDepthBuf(view.sw);
 
-      for (int i=0; i < NumLineDefs; i++)
-         AddLine (i);
+	for (int i = 0; i < NumLineDefs; i++)
+	    AddLine(i);
 
-      if (view.sprites)
-         for (int j=0; j < NumThings; j++)
-            AddThing (j);
+	if (view.sprites)
+	    for (int j = 0; j < NumThings; j++)
+		AddThing(j);
 
-      ClipSolids ();
-      ComputeSurfaces ();
-      RenderWalls ();
-      }
+	ClipSolids();
+	ComputeSurfaces();
+	RenderWalls();
+    }
 };
 
 
-static Thing *FindPlayer (int typenum)
+static Thing *FindPlayer(int typenum)
 {
-for (int i=0; i < NumThings; i++)
-   if (Things[i].type == typenum)
-      return Things + i;
+    for (int i = 0; i < NumThings; i++)
+	if (Things[i].type == typenum)
+	    return Things + i;
 
-return 0;
+    return 0;
 }
 
 
@@ -1124,152 +1137,153 @@
  *  Render a 3D view from the player's position. 
  */
 
-void Render3D ()
+void Render3D()
 {
-if (! view.p_type)
-   {
-   view.p_type = THING_PLAYER1;
-   view.px = 99999;
-   }
+    if (!view.p_type)
+    {
+	view.p_type = THING_PLAYER1;
+	view.px = 99999;
+    }
 
-Thing *player = FindPlayer (view.p_type);
+    Thing *player = FindPlayer(view.p_type);
 
-if (! player)
-   {
-   if (view.p_type != THING_DEATHMATCH)
-      view.p_type = THING_DEATHMATCH;
+    if (!player)
+    {
+	if (view.p_type != THING_DEATHMATCH)
+	    view.p_type = THING_DEATHMATCH;
 
-   player = FindPlayer (view.p_type);
+	player = FindPlayer(view.p_type);
 
-   if (! player)
-      return;
-   }
+	if (!player)
+	    return;
+    }
 
-if (view.px != player->xpos || view.py != player->ypos)
-   {
-   // if player moved, re-create view parameters
+    if (view.px != player->xpos || view.py != player->ypos)
+    {
+	// if player moved, re-create view parameters
 
-   view.x = view.px = player->xpos;
-   view.y = view.py = player->ypos;
+	view.x = view.px = player->xpos;
+	view.y = view.py = player->ypos;
 
-   view.CalcViewZ ();
-   view.SetAngle (player->angle * ONEPI / 180.0);
-   }
+	view.CalcViewZ();
+	view.SetAngle(player->angle * ONEPI / 180.0);
+    }
 
 /* create image */
 
-view.sw = 640;
-view.sh = 400;
+    view.sw = 640;
+    view.sh = 400;
 
-view.screen = new Img ((unsigned short int) view.sw, (unsigned short int) view.sh, false);
-view.im_ch = new ImageCache;
+    view.screen =
+	new Img((unsigned short int) view.sw, (unsigned short int) view.sh,
+		false);
+    view.im_ch = new ImageCache;
 
-view.FindThingFloors ();
+    view.FindThingFloors();
 
-bool Redraw = true;
+    bool Redraw = true;
 
 /* input loop */
 
-for (;;)
-   {
-   /* render image */
+    for (;;)
+    {
+	/* render image */
 
-   if (Redraw)
-      {
-      if (view.walking)
-         view.CalcViewZ ();
+	if (Redraw)
+	{
+	    if (view.walking)
+		view.CalcViewZ();
 
-      RendInfo rend;
+	    RendInfo rend;
 
-      rend.DoRender3D ();
+	    rend.DoRender3D();
 
-      view.PutScreen (40, 40);
+	    view.PutScreen(40, 40);
 
-      Redraw = false;
-      }
+	    Redraw = false;
+	}
 
-   /* handle keypress */
+	/* handle keypress */
 
-   int key = get_key ();
+	int key = get_key();
 
-   if (key == YK_ESC || key == 'q')
-      break;
+	if (key == YK_ESC || key == 'q')
+	    break;
 
-   if ((key & ~YK_SHIFT) == YK_LEFT)
-      {
-      view.SetAngle (view.angle + ONEPI / ((key & YK_SHIFT) ? 4 : 8));
-      Redraw = true;
-      }
-   else if ((key & ~YK_SHIFT) == YK_RIGHT)
-      {
-      view.SetAngle (view.angle -ONEPI / ((key & YK_SHIFT) ? 4 : 8));
-      Redraw = true;
-      }
-   else if ((key & ~YK_SHIFT) == YK_UP)
-      {
-      view.x += view.Cos * ((key & YK_SHIFT) ? 192 : 32);
-      view.y += view.Sin * ((key & YK_SHIFT) ? 192 : 32);
-      Redraw = true;
-      }
-   else if ((key & ~YK_SHIFT) == YK_DOWN)
-      {
-      view.x -= view.Cos * ((key & YK_SHIFT) ? 192 : 32);
-      view.y -= view.Sin * ((key & YK_SHIFT) ? 192 : 32);
-      Redraw = true;
-      }
-   else if (key == 'n' || key == 'N')
-      {
-      view.x -= view.Sin * ((key == 'N') ? 192 : 32);
-      view.y += view.Cos * ((key == 'N') ? 192 : 32);
-      Redraw = true;
-      }
-   else if (key == 'm' || key == 'M')
-      {
-      view.x += view.Sin * ((key == 'M') ? 192 : 32);
-      view.y -= view.Cos * ((key == 'M') ? 192 : 32);
-      Redraw = true;
-      }
-   else if (key == 'd' || key == 'D')
-      {
-      view.z += (key == 'D') ? 128 : 32;
-      Redraw = true;
-      }
-   else if (key == 'c' || key == 'C')
-      {
-      view.z -= (key == 'C') ? 128 : 32;
-      Redraw = true;
-      }
-   else if (key == 't')
-      {
-      view.texturing = ! view.texturing;
-      Redraw = true;
-      }
-   else if (key == 's')
-      {
-      view.sprites = ! view.sprites;
-      Redraw = true;
-      }
-   else if (key == 'w')
-      {
-      view.walking = ! view.walking;
-      Redraw = true;
-      }
-   else if (key)
-      {
-      // key no good, get another one
-      Beep ();
-      }
-   }
+	if ((key & ~YK_SHIFT) == YK_LEFT)
+	{
+	    view.SetAngle(view.angle + ONEPI / ((key & YK_SHIFT) ? 4 : 8));
+	    Redraw = true;
+	}
+	else if ((key & ~YK_SHIFT) == YK_RIGHT)
+	{
+	    view.SetAngle(view.angle - ONEPI / ((key & YK_SHIFT) ? 4 : 8));
+	    Redraw = true;
+	}
+	else if ((key & ~YK_SHIFT) == YK_UP)
+	{
+	    view.x += view.Cos * ((key & YK_SHIFT) ? 192 : 32);
+	    view.y += view.Sin * ((key & YK_SHIFT) ? 192 : 32);
+	    Redraw = true;
+	}
+	else if ((key & ~YK_SHIFT) == YK_DOWN)
+	{
+	    view.x -= view.Cos * ((key & YK_SHIFT) ? 192 : 32);
+	    view.y -= view.Sin * ((key & YK_SHIFT) ? 192 : 32);
+	    Redraw = true;
+	}
+	else if (key == 'n' || key == 'N')
+	{
+	    view.x -= view.Sin * ((key == 'N') ? 192 : 32);
+	    view.y += view.Cos * ((key == 'N') ? 192 : 32);
+	    Redraw = true;
+	}
+	else if (key == 'm' || key == 'M')
+	{
+	    view.x += view.Sin * ((key == 'M') ? 192 : 32);
+	    view.y -= view.Cos * ((key == 'M') ? 192 : 32);
+	    Redraw = true;
+	}
+	else if (key == 'd' || key == 'D')
+	{
+	    view.z += (key == 'D') ? 128 : 32;
+	    Redraw = true;
+	}
+	else if (key == 'c' || key == 'C')
+	{
+	    view.z -= (key == 'C') ? 128 : 32;
+	    Redraw = true;
+	}
+	else if (key == 't')
+	{
+	    view.texturing = !view.texturing;
+	    Redraw = true;
+	}
+	else if (key == 's')
+	{
+	    view.sprites = !view.sprites;
+	    Redraw = true;
+	}
+	else if (key == 'w')
+	{
+	    view.walking = !view.walking;
+	    Redraw = true;
+	}
+	else if (key)
+	{
+	    // key no good, get another one
+	    Beep();
+	}
+    }
 
 /* all done */
 
-delete view.screen;
-view.screen = 0;
+    delete view.screen;
+    view.screen = 0;
 
-delete view.im_ch;
-view.im_ch = 0;
+    delete view.im_ch;
+    view.im_ch = 0;
 
-delete[] view.thing_floors;
-view.thing_floors = 0;
+    delete[]view.thing_floors;
+    view.thing_floors = 0;
 }
-
--- a/src/r_render.h	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/r_render.h	Sat Sep 24 14:16:04 2011 +0300
@@ -4,11 +4,11 @@
  */
 
 
-#ifndef YH_R_RENDER  /* DO NOT INSERT ANYTHING BEFORE THIS LINE */
+#ifndef YH_R_RENDER		/* DO NOT INSERT ANYTHING BEFORE THIS LINE */
 #define YH_R_RENDER
 
 
-void Render3D ();
+void Render3D();
 
 
-#endif  /* DO NOT ADD ANYTHING AFTER THIS LINE */
+#endif /* DO NOT ADD ANYTHING AFTER THIS LINE */
--- a/src/record.h	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/record.h	Sat Sep 24 14:16:04 2011 +0300
@@ -4,20 +4,18 @@
  */
 
 
-#ifndef YH_RECORD  /* DO NOT INSERT ANYTHING BEFORE THIS LINE */
+#ifndef YH_RECORD		/* DO NOT INSERT ANYTHING BEFORE THIS LINE */
 #define YH_RECORD
 
 
-class Recording 
+class Recording
 {
-  public :
-    read ();
-    write ();
+    public:read();
+    write();
 
-  private :
-    class priv;
+    private:class priv;
     priv *p;
 };
 
 
-#endif  /* DO NOT ADD ANYTHING AFTER THIS LINE */
+#endif /* DO NOT ADD ANYTHING AFTER THIS LINE */
--- a/src/rgb.h	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/rgb.h	Sat Sep 24 14:16:04 2011 +0300
@@ -27,44 +27,43 @@
 */
 
 
-#ifndef YH_RGB  /* Prevent multiple inclusion */
-#define YH_RGB  /* Prevent multiple inclusion */
+#ifndef YH_RGB			/* Prevent multiple inclusion */
+#define YH_RGB			/* Prevent multiple inclusion */
 
 
 class rgb_c
-   {
-   public :
-      rgb_c ()
-         {
-         }
+{
+    public: rgb_c()
+    {
+    }
 
-      // Must be defined before rbg_c (r, g, b)
-      void set (u8 red, u8 green, u8 blue)
-         {
-         r = red;
-         g = green;
-         b = blue;
-         }
+    // Must be defined before rbg_c (r, g, b)
+    void set(u8 red, u8 green, u8 blue)
+    {
+	r = red;
+	g = green;
+	b = blue;
+    }
 
-      rgb_c (u8 red, u8 green, u8 blue)
-         {
-         set (red, green, blue);
-         }
+    rgb_c(u8 red, u8 green, u8 blue)
+    {
+	set(red, green, blue);
+    }
 
-      int operator == (const rgb_c& rgb2) const
-         {
-         return rgb2.r == r && rgb2.g == g && rgb2.b == b;
-         }
+    int operator ==(const rgb_c & rgb2) const
+    {
+	return rgb2.r == r && rgb2.g == g && rgb2.b == b;
+    }
 
-      int operator - (const rgb_c& rgb2) const
-         {
-         return abs (rgb2.r - r) + abs (rgb2.g - g) + abs (rgb2.b - b);
-         }
+    int operator -(const rgb_c & rgb2) const
+    {
+	return abs(rgb2.r - r) + abs(rgb2.g - g) + abs(rgb2.b - b);
+    }
 
-      u8 r;
-      u8 g;
-      u8 b;
-   };
+    u8 r;
+    u8 g;
+    u8 b;
+};
 
 
-#endif  /* DO NOT ADD ANYTHING AFTER THIS LINE */
+#endif /* DO NOT ADD ANYTHING AFTER THIS LINE */
--- a/src/rgbbmp.h	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/rgbbmp.h	Sat Sep 24 14:16:04 2011 +0300
@@ -31,116 +31,114 @@
 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
 Place, Suite 330, Boston, MA 02111-1307, USA.
 */
- 
- 
+
+
 #ifndef YH_RGBBMP
 #define YH_RGBBMP
 
 
 typedef struct
 {
-  u8 r;
-  u8 g;
-  u8 b;
+    u8 r;
+    u8 g;
+    u8 b;
 } Rgbbmp_pixel_t;
 
 
 class Rgbbmp
 {
-  public :
-
-    Rgbbmp ()
+    public:Rgbbmp()
     {
-      _width = 0;
-      _height = 0;
-      pixel = 0;
+	_width = 0;
+	_height = 0;
+	pixel = 0;
     }
 
-    void resize (int width, int height)  // Must be defined before first use
+    void resize(int width, int height)	// Must be defined before first use
     {
-      _width  = width;
-      _height = height;
-      if (pixel)
-	delete[] pixel;
-      if (width * height > 0)
-        pixel = new Rgbbmp_pixel_t[width * height];
-      else
-	pixel = 0;
+	_width = width;
+	_height = height;
+	if (pixel)
+	    delete[]pixel;
+	if (width * height > 0)
+	    pixel = new Rgbbmp_pixel_t[width * height];
+	else
+	    pixel = 0;
     };
 
-    Rgbbmp (int width, int height)
+    Rgbbmp(int width, int height)
     {
-      pixel = 0;
-      resize (width, height);
+	pixel = 0;
+	resize(width, height);
     }
 
-    ~Rgbbmp ()
+    ~Rgbbmp()
     {
-      if (pixel)
-	delete[] pixel;
+	if (pixel)
+	    delete[]pixel;
     }
 
-    int width () const
+    int width() const
     {
-      return _width;
+	return _width;
     }
 
-    int height () const
+    int height() const
     {
-      return _height;
+	return _height;
     }
 
-    void clear ()
+    void clear()
     {
-      if (pixel)
-	memset (pixel, 0, _width * _height * sizeof *pixel);
+	if (pixel)
+	    memset(pixel, 0, _width * _height * sizeof *pixel);
     }
 
-    void get (int x, int y, u8 &r, u8 &g, u8 &b) const
+    void get(int x, int y, u8 & r, u8 & g, u8 & b) const
     {
-      r = pixel[y * _width + x].r;
-      g = pixel[y * _width + x].g;
-      b = pixel[y * _width + x].b;
+	r = pixel[y * _width + x].r;
+	g = pixel[y * _width + x].g;
+	b = pixel[y * _width + x].b;
     }
 
-    u8 get_r (int x, int y) const
+    u8 get_r(int x, int y) const
     {
-      return pixel[y * _width + x].r;
+	return pixel[y * _width + x].r;
     }
 
-    u8 get_g (int x, int y) const
+    u8 get_g(int x, int y) const
     {
-      return pixel[y * _width + x].g;
+	return pixel[y * _width + x].g;
     }
 
-    u8 get_b (int x, int y) const
+    u8 get_b(int x, int y) const
     {
-      return pixel[y * _width + x].b;
+	return pixel[y * _width + x].b;
     }
 
-    void set (int x, int y, u8 r, u8 g, u8 b)
+    void set(int x, int y, u8 r, u8 g, u8 b)
     {
-      pixel[y * _width + x].r = r;
-      pixel[y * _width + x].g = g;
-      pixel[y * _width + x].b = b;
+	pixel[y * _width + x].r = r;
+	pixel[y * _width + x].g = g;
+	pixel[y * _width + x].b = b;
     }
 
-    void set_r (int x, int y, u8 r)
+    void set_r(int x, int y, u8 r)
     {
-      pixel[y * _width + x].r = r;
+	pixel[y * _width + x].r = r;
     }
 
-    void set_g (int x, int y, u8 g)
+    void set_g(int x, int y, u8 g)
     {
-      pixel[y * _width + x].g = g;
+	pixel[y * _width + x].g = g;
     }
 
-    void set_b (int x, int y, u8 b)
+    void set_b(int x, int y, u8 b)
     {
-      pixel[y * _width + x].b = b;
+	pixel[y * _width + x].b = b;
     }
 
-  private :
+  private:
 
     int _width;
     int _height;
@@ -148,4 +146,4 @@
 };
 
 
-#endif  /* DO NOT ADD ANYTHING AFTER THIS LINE */
+#endif /* DO NOT ADD ANYTHING AFTER THIS LINE */
--- a/src/s_centre.cc	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/s_centre.cc	Sat Sep 24 14:16:04 2011 +0300
@@ -42,31 +42,31 @@
  *	does not take into account concave sectors and sectors
  *	that are enclosed by several distinct paths of linedefs.
  */
-void centre_of_sector (obj_no_t s, int *x, int *y)
+void centre_of_sector(obj_no_t s, int *x, int *y)
 {
-bitvec_c *vertices = bv_vertices_of_sector (s);
-long x_sum  = 0;
-long y_sum  = 0;
-int  nitems = 0;
+    bitvec_c *vertices = bv_vertices_of_sector(s);
+    long x_sum = 0;
+    long y_sum = 0;
+    int nitems = 0;
 
-for (size_t n = 0; n < vertices->nelements (); n++)
-   if (vertices->get (n))
-      {
-      x_sum += Vertices[n].x;
-      y_sum += Vertices[n].y;
-      nitems++;
-      }
-if (nitems == 0)
-   {
-   *x = 0;
-   *y = 0;
-   }
-else
-   {
-   *x = (int) (x_sum / nitems);
-   *y = (int) (y_sum / nitems);
-   }
-delete vertices;
+    for (size_t n = 0; n < vertices->nelements(); n++)
+	if (vertices->get(n))
+	{
+	    x_sum += Vertices[n].x;
+	    y_sum += Vertices[n].y;
+	    nitems++;
+	}
+    if (nitems == 0)
+    {
+	*x = 0;
+	*y = 0;
+    }
+    else
+    {
+	*x = (int) (x_sum / nitems);
+	*y = (int) (y_sum / nitems);
+    }
+    delete vertices;
 }
 
 
@@ -74,36 +74,34 @@
  *	centre_of_sectors
  *	Return the coordinates of the centre of a group of sectors.
  */
-void centre_of_sectors (SelPtr list, int *x, int *y)
+void centre_of_sectors(SelPtr list, int *x, int *y)
 {
-bitvec_c *vertices;
-int nitems;
-long x_sum;
-long y_sum;
-int n;
+    bitvec_c *vertices;
+    int nitems;
+    long x_sum;
+    long y_sum;
+    int n;
 
-vertices = bv_vertices_of_sectors (list);
-x_sum = 0;
-y_sum = 0;
-nitems = 0;
-for (n = 0; n < NumVertices; n++)
-   if (vertices->get (n))
-      {
-      x_sum += Vertices[n].x;
-      y_sum += Vertices[n].y;
-      nitems++;
-      }
-if (nitems == 0)
-   {
-   *x = 0;
-   *y = 0;
-   }
-else
-   {
-   *x = (int) (x_sum / nitems);
-   *y = (int) (y_sum / nitems);
-   }
-delete vertices;
+    vertices = bv_vertices_of_sectors(list);
+    x_sum = 0;
+    y_sum = 0;
+    nitems = 0;
+    for (n = 0; n < NumVertices; n++)
+	if (vertices->get(n))
+	{
+	    x_sum += Vertices[n].x;
+	    y_sum += Vertices[n].y;
+	    nitems++;
+	}
+    if (nitems == 0)
+    {
+	*x = 0;
+	*y = 0;
+    }
+    else
+    {
+	*x = (int) (x_sum / nitems);
+	*y = (int) (y_sum / nitems);
+    }
+    delete vertices;
 }
-
-
--- a/src/s_centre.h	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/s_centre.h	Sat Sep 24 14:16:04 2011 +0300
@@ -7,7 +7,5 @@
 #include "objid.h"
 
 
-void centre_of_sector (obj_no_t s, int *x, int *y);
-void centre_of_sectors (SelPtr list, int *x, int *y);
-
-
+void centre_of_sector(obj_no_t s, int *x, int *y);
+void centre_of_sectors(SelPtr list, int *x, int *y);
--- a/src/s_door.cc	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/s_door.cc	Sat Sep 24 14:16:04 2011 +0300
@@ -39,104 +39,105 @@
    turn a sector into a door: change the linedefs and sidedefs
 */
 
-void MakeDoorFromSector (int sector) /* SWAP! */
-{
-int    sd1, sd2;
-int    n, s;
-SelPtr ldok, ldflip, ld1s;
-
-ldok = NULL;
-ldflip = NULL;
-ld1s = NULL;
-s = 0;
-/* build lists of linedefs that border the sector */
-for (n = 0; n < NumLineDefs; n++)
+void MakeDoorFromSector(int sector)	/* SWAP! */
 {
-   sd1 = LineDefs[n].sidedef1;
-   sd2 = LineDefs[n].sidedef2;
-   if (sd1 >= 0 && sd2 >= 0)
-   {
-      if (SideDefs[sd2].sector == sector)
-      {
-	 SelectObject (&ldok, n); /* already ok */
-	 s++;
-      }
-      if (SideDefs[sd1].sector == sector)
-      {
-	 SelectObject (&ldflip, n); /* must be flipped */
-	 s++;
-      }
-   }
-   else if (sd1 >= 0 && sd2 < 0)
-   {
-      if (SideDefs[sd1].sector == sector)
-	 SelectObject (&ld1s, n); /* wall (one-sided) */
-   }
-}
+    int sd1, sd2;
+    int n, s;
+    SelPtr ldok, ldflip, ld1s;
+
+    ldok = NULL;
+    ldflip = NULL;
+    ld1s = NULL;
+    s = 0;
+/* build lists of linedefs that border the sector */
+    for (n = 0; n < NumLineDefs; n++)
+    {
+	sd1 = LineDefs[n].sidedef1;
+	sd2 = LineDefs[n].sidedef2;
+	if (sd1 >= 0 && sd2 >= 0)
+	{
+	    if (SideDefs[sd2].sector == sector)
+	    {
+		SelectObject(&ldok, n);	/* already ok */
+		s++;
+	    }
+	    if (SideDefs[sd1].sector == sector)
+	    {
+		SelectObject(&ldflip, n);	/* must be flipped */
+		s++;
+	    }
+	}
+	else if (sd1 >= 0 && sd2 < 0)
+	{
+	    if (SideDefs[sd1].sector == sector)
+		SelectObject(&ld1s, n);	/* wall (one-sided) */
+	}
+    }
 /* a normal door has two sides... */
-if (s < 2)
-{
-   Beep ();
-   Notify (-1, -1, "The door must be connected to two other Sectors.", NULL);
-   ForgetSelection (&ldok);
-   ForgetSelection (&ldflip);
-   ForgetSelection (&ld1s);
-   return;
-}
-if ((s > 2) && !(Expert || Confirm (-1, -1, "The door will have more than two sides.", "Do you still want to create it?")))
-{
-   ForgetSelection (&ldok);
-   ForgetSelection (&ldflip);
-   ForgetSelection (&ld1s);
-   return;
+    if (s < 2)
+    {
+	Beep();
+	Notify(-1, -1, "The door must be connected to two other Sectors.",
+	       NULL);
+	ForgetSelection(&ldok);
+	ForgetSelection(&ldflip);
+	ForgetSelection(&ld1s);
+	return;
+    }
+    if ((s > 2)
+	&& !(Expert
+	     || Confirm(-1, -1, "The door will have more than two sides.",
+			"Do you still want to create it?")))
+    {
+	ForgetSelection(&ldok);
+	ForgetSelection(&ldflip);
+	ForgetSelection(&ld1s);
+	return;
+    }
+/* flip the linedefs that have the wrong orientation */
+    if (ldflip != NULL)
+	FlipLineDefs(ldflip, 1);
+/* merge the two selection lists */
+    while (ldflip != NULL)
+    {
+	if (!IsSelected(ldok, ldflip->objnum))
+	    SelectObject(&ldok, ldflip->objnum);
+	UnSelectObject(&ldflip, ldflip->objnum);
+    }
+/* change the linedefs and sidedefs */
+    while (ldok != NULL)
+    {
+	/* give the "normal door" type and flags to the linedef */
+	n = ldok->objnum;
+	LineDefs[n].type = 1;
+	LineDefs[n].flags = 0x04;
+	sd1 = LineDefs[n].sidedef1;	/* outside */
+	sd2 = LineDefs[n].sidedef2;	/* inside */
+	/* adjust the textures for the sidedefs */
+	if (strncmp(SideDefs[sd1].tex3, "-", WAD_TEX_NAME))
+	{
+	    if (!strncmp(SideDefs[sd1].tex1, "-", WAD_TEX_NAME))
+		strncpy(SideDefs[sd1].tex1, SideDefs[sd1].tex3, WAD_TEX_NAME);
+	    strncpy(SideDefs[sd1].tex3, "-", WAD_TEX_NAME);
+	}
+	if (!strncmp(SideDefs[sd1].tex1, "-", WAD_TEX_NAME))
+	    strncpy(SideDefs[sd1].tex1, "BIGDOOR2", WAD_TEX_NAME);
+	strncpy(SideDefs[sd2].tex3, "-", WAD_TEX_NAME);
+	UnSelectObject(&ldok, n);
+    }
+    while (ld1s != NULL)
+    {
+	/* give the "door side" flags to the linedef */
+	n = ld1s->objnum;
+	LineDefs[n].flags = 0x11;
+	sd1 = LineDefs[n].sidedef1;
+	/* adjust the textures for the sidedef */
+	if (!strncmp(SideDefs[sd1].tex3, "-", WAD_TEX_NAME))
+	    strncpy(SideDefs[sd1].tex3, "DOORTRAK", WAD_TEX_NAME);
+	strncpy(SideDefs[sd1].tex1, "-", WAD_TEX_NAME);
+	strncpy(SideDefs[sd1].tex2, "-", WAD_TEX_NAME);
+	UnSelectObject(&ld1s, n);
+    }
+/* adjust the ceiling height */
+    Sectors[sector].ceilh = Sectors[sector].floorh;
 }
-/* flip the linedefs that have the wrong orientation */
-if (ldflip != NULL)
-   FlipLineDefs (ldflip, 1);
-/* merge the two selection lists */
-while (ldflip != NULL)
-{
-   if (!IsSelected (ldok, ldflip->objnum))
-      SelectObject (&ldok, ldflip->objnum);
-   UnSelectObject (&ldflip, ldflip->objnum);
-}
-/* change the linedefs and sidedefs */
-while (ldok != NULL)
-{
-   /* give the "normal door" type and flags to the linedef */
-   n = ldok->objnum;
-   LineDefs[n].type = 1;
-   LineDefs[n].flags = 0x04;
-   sd1 = LineDefs[n].sidedef1; /* outside */
-   sd2 = LineDefs[n].sidedef2; /* inside */
-   /* adjust the textures for the sidedefs */
-   if (strncmp (SideDefs[sd1].tex3, "-", WAD_TEX_NAME))
-   {
-      if (!strncmp (SideDefs[sd1].tex1, "-", WAD_TEX_NAME))
-	 strncpy (SideDefs[sd1].tex1, SideDefs[sd1].tex3, WAD_TEX_NAME);
-      strncpy (SideDefs[sd1].tex3, "-", WAD_TEX_NAME);
-   }
-   if (!strncmp (SideDefs[sd1].tex1, "-", WAD_TEX_NAME))
-      strncpy (SideDefs[sd1].tex1, "BIGDOOR2", WAD_TEX_NAME);
-   strncpy (SideDefs[sd2].tex3, "-", WAD_TEX_NAME);
-   UnSelectObject (&ldok, n);
-}
-while (ld1s != NULL)
-{
-   /* give the "door side" flags to the linedef */
-   n = ld1s->objnum;
-   LineDefs[n].flags = 0x11;
-   sd1 = LineDefs[n].sidedef1;
-   /* adjust the textures for the sidedef */
-   if (!strncmp (SideDefs[sd1].tex3, "-", WAD_TEX_NAME))
-      strncpy (SideDefs[sd1].tex3, "DOORTRAK", WAD_TEX_NAME);
-   strncpy (SideDefs[sd1].tex1, "-", WAD_TEX_NAME);
-   strncpy (SideDefs[sd1].tex2, "-", WAD_TEX_NAME);
-   UnSelectObject (&ld1s, n);
-}
-/* adjust the ceiling height */
-Sectors[sector].ceilh = Sectors[sector].floorh;
-}
-
-
-
--- a/src/s_lift.cc	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/s_lift.cc	Sat Sep 24 14:16:04 2011 +0300
@@ -40,165 +40,166 @@
    turn a Sector into a lift: change the linedefs and sidedefs
 */
 
-void MakeLiftFromSector (int sector) /* SWAP! */
-{
-int    sd1, sd2;
-int    n, s, tag;
-SelPtr ldok, ldflip, ld1s;
-SelPtr sect, curs;
-int    minh, maxh;
-
-ldok = NULL;
-ldflip = NULL;
-ld1s = NULL;
-sect = NULL;
-/* build lists of linedefs that border the Sector */
-for (n = 0; n < NumLineDefs; n++)
+void MakeLiftFromSector(int sector)	/* SWAP! */
 {
-   sd1 = LineDefs[n].sidedef1;
-   sd2 = LineDefs[n].sidedef2;
-   if (sd1 >= 0 && sd2 >= 0)
-   {
-      if (SideDefs[sd2].sector == sector)
-      {
-	 SelectObject (&ldok, n); /* already ok */
-	 s = SideDefs[sd1].sector;
-	 if (s != sector && !IsSelected (sect, s))
-	    SelectObject (&sect, s);
-      }
-      if (SideDefs[sd1].sector == sector)
-      {
-	 SelectObject (&ldflip, n); /* will be flipped */
-	 s = SideDefs[sd2].sector;
-	 if (s != sector && !IsSelected (sect, s))
-	    SelectObject (&sect, s);
-      }
-   }
-   else if (sd1 >= 0 && sd2 < 0)
-   {
-      if (SideDefs[sd1].sector == sector)
-	 SelectObject (&ld1s, n); /* wall (one-sided) */
-   }
-}
+    int sd1, sd2;
+    int n, s, tag;
+    SelPtr ldok, ldflip, ld1s;
+    SelPtr sect, curs;
+    int minh, maxh;
+
+    ldok = NULL;
+    ldflip = NULL;
+    ld1s = NULL;
+    sect = NULL;
+/* build lists of linedefs that border the Sector */
+    for (n = 0; n < NumLineDefs; n++)
+    {
+	sd1 = LineDefs[n].sidedef1;
+	sd2 = LineDefs[n].sidedef2;
+	if (sd1 >= 0 && sd2 >= 0)
+	{
+	    if (SideDefs[sd2].sector == sector)
+	    {
+		SelectObject(&ldok, n);	/* already ok */
+		s = SideDefs[sd1].sector;
+		if (s != sector && !IsSelected(sect, s))
+		    SelectObject(&sect, s);
+	    }
+	    if (SideDefs[sd1].sector == sector)
+	    {
+		SelectObject(&ldflip, n);	/* will be flipped */
+		s = SideDefs[sd2].sector;
+		if (s != sector && !IsSelected(sect, s))
+		    SelectObject(&sect, s);
+	    }
+	}
+	else if (sd1 >= 0 && sd2 < 0)
+	{
+	    if (SideDefs[sd1].sector == sector)
+		SelectObject(&ld1s, n);	/* wall (one-sided) */
+	}
+    }
 /* there must be a way to go on the lift... */
-if (sect == NULL)
-{
-   Beep ();
-   Notify (-1, -1, "The lift must be connected to at least one other Sector.", NULL);
-   ForgetSelection (&ldok);
-   ForgetSelection (&ldflip);
-   ForgetSelection (&ld1s);
-   return;
-}
+    if (sect == NULL)
+    {
+	Beep();
+	Notify(-1, -1,
+	       "The lift must be connected to at least one other Sector.",
+	       NULL);
+	ForgetSelection(&ldok);
+	ForgetSelection(&ldflip);
+	ForgetSelection(&ld1s);
+	return;
+    }
 /* flip the linedefs that have the wrong orientation */
-if (ldflip != NULL)
-   FlipLineDefs (ldflip, 1);
+    if (ldflip != NULL)
+	FlipLineDefs(ldflip, 1);
 /* merge the two selection lists */
-while (ldflip != NULL)
-{
-   if (!IsSelected (ldok, ldflip->objnum))
-      SelectObject (&ldok, ldflip->objnum);
-   UnSelectObject (&ldflip, ldflip->objnum);
-}
+    while (ldflip != NULL)
+    {
+	if (!IsSelected(ldok, ldflip->objnum))
+	    SelectObject(&ldok, ldflip->objnum);
+	UnSelectObject(&ldflip, ldflip->objnum);
+    }
 
 /* find a free tag number */
-tag = FindFreeTag ();
+    tag = FindFreeTag();
 
 /* find the minimum and maximum altitudes */
-minh = 32767;
-maxh = -32767;
-for (curs = sect; curs; curs = curs->next)
-   {
-   if (Sectors[curs->objnum].floorh < minh)
-      minh = Sectors[curs->objnum].floorh;
-   if (Sectors[curs->objnum].floorh > maxh)
-      maxh = Sectors[curs->objnum].floorh;
-   }
-ForgetSelection (&sect);
+    minh = 32767;
+    maxh = -32767;
+    for (curs = sect; curs; curs = curs->next)
+    {
+	if (Sectors[curs->objnum].floorh < minh)
+	    minh = Sectors[curs->objnum].floorh;
+	if (Sectors[curs->objnum].floorh > maxh)
+	    maxh = Sectors[curs->objnum].floorh;
+    }
+    ForgetSelection(&sect);
 
 /* change the lift's floor height if necessary */
-if (Sectors[sector].floorh < maxh)
-   Sectors[sector].floorh = maxh;
+    if (Sectors[sector].floorh < maxh)
+	Sectors[sector].floorh = maxh;
 
 /* change the lift's ceiling height if necessary */
-if (Sectors[sector].ceilh < maxh + DOOM_PLAYER_HEIGHT)
-   Sectors[sector].ceilh = maxh + DOOM_PLAYER_HEIGHT;
+    if (Sectors[sector].ceilh < maxh + DOOM_PLAYER_HEIGHT)
+	Sectors[sector].ceilh = maxh + DOOM_PLAYER_HEIGHT;
 
 /* assign the new tag number to the lift */
-Sectors[sector].tag = tag;
+    Sectors[sector].tag = tag;
 
 /* change the linedefs and sidedefs */
-while (ldok != NULL)
-   {
-   /* give the "lower lift" type and flags to the linedef */
-   n = ldok->objnum;
-   LineDefs[n].type = 62; /* lower lift (switch) */
-   LineDefs[n].flags = 0x04;
-   LineDefs[n].tag = tag;
-   sd1 = LineDefs[n].sidedef1; /* outside */
-   sd2 = LineDefs[n].sidedef2; /* inside */
-   /* adjust the textures for the sidedef visible from the outside */
-   if (strncmp (SideDefs[sd1].tex3, "-", WAD_TEX_NAME))
-      {
-      if (!strncmp (SideDefs[sd1].tex2, "-", WAD_TEX_NAME))
-	 strncpy (SideDefs[sd1].tex2, SideDefs[sd1].tex3, WAD_TEX_NAME);
-      strncpy (SideDefs[sd1].tex3, "-", WAD_TEX_NAME);
-      }
-   if (!strncmp (SideDefs[sd1].tex2, "-", WAD_TEX_NAME))
-      strncpy (SideDefs[sd1].tex2, "SHAWN2", WAD_TEX_NAME);
-   /* adjust the textures for the sidedef visible from the lift */
-   strncpy (SideDefs[sd2].tex3, "-", WAD_TEX_NAME);
-   s = SideDefs[sd1].sector;
-   if (Sectors[s].floorh > minh)
-      {
-      if (strncmp (SideDefs[sd2].tex3, "-", WAD_TEX_NAME))
-      {
-	 if (!strncmp (SideDefs[sd2].tex2, "-", WAD_TEX_NAME))
-	    strncpy (SideDefs[sd2].tex2, SideDefs[sd1].tex3, WAD_TEX_NAME);
-	 strncpy (SideDefs[sd2].tex3, "-", WAD_TEX_NAME);
-      }
-      if (!strncmp (SideDefs[sd2].tex2, "-", WAD_TEX_NAME))
-	 strncpy (SideDefs[sd2].tex2, "SHAWN2", WAD_TEX_NAME);
-      }
-   else
-      {
-      strncpy (SideDefs[sd2].tex2, "-", WAD_TEX_NAME);
-      }
-   strncpy (SideDefs[sd2].tex3, "-", WAD_TEX_NAME);
-   /* if the ceiling of the sector is lower than that of the lift */
-   if (Sectors[s].ceilh < Sectors[sector].ceilh)
-      {
-      if (strncmp (SideDefs[sd2].tex1, "-", WAD_TEX_NAME))
-	 strncpy (SideDefs[sd2].tex1, default_upper_texture, WAD_TEX_NAME);
-      }
-   /* if the floor of the sector is above the lift */
-   if (Sectors[s].floorh >= Sectors[sector].floorh)
-      {
-      LineDefs[n].type = 88; /* lower lift (walk through) */
-      /* flip it, just for fun */
-      curs = NULL;
-      SelectObject (&curs, n);
-      FlipLineDefs (curs, 1);
-      ForgetSelection (&curs);
-      }
-   /* done with this linedef */
-   UnSelectObject (&ldok, n);
-   }
+    while (ldok != NULL)
+    {
+	/* give the "lower lift" type and flags to the linedef */
+	n = ldok->objnum;
+	LineDefs[n].type = 62;	/* lower lift (switch) */
+	LineDefs[n].flags = 0x04;
+	LineDefs[n].tag = tag;
+	sd1 = LineDefs[n].sidedef1;	/* outside */
+	sd2 = LineDefs[n].sidedef2;	/* inside */
+	/* adjust the textures for the sidedef visible from the outside */
+	if (strncmp(SideDefs[sd1].tex3, "-", WAD_TEX_NAME))
+	{
+	    if (!strncmp(SideDefs[sd1].tex2, "-", WAD_TEX_NAME))
+		strncpy(SideDefs[sd1].tex2, SideDefs[sd1].tex3, WAD_TEX_NAME);
+	    strncpy(SideDefs[sd1].tex3, "-", WAD_TEX_NAME);
+	}
+	if (!strncmp(SideDefs[sd1].tex2, "-", WAD_TEX_NAME))
+	    strncpy(SideDefs[sd1].tex2, "SHAWN2", WAD_TEX_NAME);
+	/* adjust the textures for the sidedef visible from the lift */
+	strncpy(SideDefs[sd2].tex3, "-", WAD_TEX_NAME);
+	s = SideDefs[sd1].sector;
+	if (Sectors[s].floorh > minh)
+	{
+	    if (strncmp(SideDefs[sd2].tex3, "-", WAD_TEX_NAME))
+	    {
+		if (!strncmp(SideDefs[sd2].tex2, "-", WAD_TEX_NAME))
+		    strncpy(SideDefs[sd2].tex2, SideDefs[sd1].tex3,
+			    WAD_TEX_NAME);
+		strncpy(SideDefs[sd2].tex3, "-", WAD_TEX_NAME);
+	    }
+	    if (!strncmp(SideDefs[sd2].tex2, "-", WAD_TEX_NAME))
+		strncpy(SideDefs[sd2].tex2, "SHAWN2", WAD_TEX_NAME);
+	}
+	else
+	{
+	    strncpy(SideDefs[sd2].tex2, "-", WAD_TEX_NAME);
+	}
+	strncpy(SideDefs[sd2].tex3, "-", WAD_TEX_NAME);
+	/* if the ceiling of the sector is lower than that of the lift */
+	if (Sectors[s].ceilh < Sectors[sector].ceilh)
+	{
+	    if (strncmp(SideDefs[sd2].tex1, "-", WAD_TEX_NAME))
+		strncpy(SideDefs[sd2].tex1, default_upper_texture,
+			WAD_TEX_NAME);
+	}
+	/* if the floor of the sector is above the lift */
+	if (Sectors[s].floorh >= Sectors[sector].floorh)
+	{
+	    LineDefs[n].type = 88;	/* lower lift (walk through) */
+	    /* flip it, just for fun */
+	    curs = NULL;
+	    SelectObject(&curs, n);
+	    FlipLineDefs(curs, 1);
+	    ForgetSelection(&curs);
+	}
+	/* done with this linedef */
+	UnSelectObject(&ldok, n);
+    }
 
-while (ld1s != NULL)
-   {
-   /* these are the lift walls (one-sided) */
-   n = ld1s->objnum;
-   LineDefs[n].flags = 0x01;
-   sd1 = LineDefs[n].sidedef1;
-   /* adjust the textures for the sidedef */
-   if (!strncmp (SideDefs[sd1].tex3, "-", WAD_TEX_NAME))
-      strncpy (SideDefs[sd1].tex3, default_middle_texture, WAD_TEX_NAME);
-   strncpy (SideDefs[sd1].tex1, "-", WAD_TEX_NAME);
-   strncpy (SideDefs[sd1].tex2, "-", WAD_TEX_NAME);
-   UnSelectObject (&ld1s, n);
-   }
+    while (ld1s != NULL)
+    {
+	/* these are the lift walls (one-sided) */
+	n = ld1s->objnum;
+	LineDefs[n].flags = 0x01;
+	sd1 = LineDefs[n].sidedef1;
+	/* adjust the textures for the sidedef */
+	if (!strncmp(SideDefs[sd1].tex3, "-", WAD_TEX_NAME))
+	    strncpy(SideDefs[sd1].tex3, default_middle_texture, WAD_TEX_NAME);
+	strncpy(SideDefs[sd1].tex1, "-", WAD_TEX_NAME);
+	strncpy(SideDefs[sd1].tex2, "-", WAD_TEX_NAME);
+	UnSelectObject(&ld1s, n);
+    }
 }
-
-
-
--- a/src/s_linedefs.cc	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/s_linedefs.cc	Sat Sep 24 14:16:04 2011 +0300
@@ -41,16 +41,16 @@
  *	Return a bit vector of all linedefs used by the sector.
  *	It's up to the caller to delete the bit vector after use.
  */
-bitvec_c *linedefs_of_sector (obj_no_t s)
+bitvec_c *linedefs_of_sector(obj_no_t s)
 {
-bitvec_c *linedefs = new bitvec_c (NumLineDefs);
-for (int n = 0; n < NumLineDefs; n++)
-   if (is_sidedef (LineDefs[n].sidedef1)
-       && SideDefs[LineDefs[n].sidedef1].sector == s
-    || is_sidedef (LineDefs[n].sidedef2)
-       && SideDefs[LineDefs[n].sidedef2].sector == s)
-      linedefs->set (n);
-return linedefs;
+    bitvec_c *linedefs = new bitvec_c(NumLineDefs);
+    for (int n = 0; n < NumLineDefs; n++)
+	if (is_sidedef(LineDefs[n].sidedef1)
+	    && SideDefs[LineDefs[n].sidedef1].sector == s
+	    || is_sidedef(LineDefs[n].sidedef2)
+	    && SideDefs[LineDefs[n].sidedef2].sector == s)
+	    linedefs->set(n);
+    return linedefs;
 }
 
 
@@ -59,18 +59,18 @@
  *	Return a bit vector of all linedefs used by the sectors.
  *	It's up to the caller to delete the bit vector after use.
  */
-bitvec_c *linedefs_of_sectors (SelPtr list)
+bitvec_c *linedefs_of_sectors(SelPtr list)
 {
-bitvec_c *sectors  = list_to_bitvec (list, NumSectors);
-bitvec_c *linedefs = new bitvec_c (NumLineDefs);
-for (int n = 0; n < NumLineDefs; n++)
-   if (   is_sidedef (LineDefs[n].sidedef1)
-          && sectors->get (SideDefs[LineDefs[n].sidedef1].sector)
-       || is_sidedef (LineDefs[n].sidedef2)
-          && sectors->get (SideDefs[LineDefs[n].sidedef2].sector))
-      linedefs->set (n);
-delete sectors;
-return linedefs;
+    bitvec_c *sectors = list_to_bitvec(list, NumSectors);
+    bitvec_c *linedefs = new bitvec_c(NumLineDefs);
+    for (int n = 0; n < NumLineDefs; n++)
+	if (is_sidedef(LineDefs[n].sidedef1)
+	    && sectors->get(SideDefs[LineDefs[n].sidedef1].sector)
+	    || is_sidedef(LineDefs[n].sidedef2)
+	    && sectors->get(SideDefs[LineDefs[n].sidedef2].sector))
+	    linedefs->set(n);
+    delete sectors;
+    return linedefs;
 }
 
 
@@ -82,27 +82,25 @@
  *	numbers of those linedefs. It's up to the caller to
  *	delete[] the array after use.
  */
-int linedefs_of_sector (obj_no_t s, obj_no_t *&array)
+int linedefs_of_sector(obj_no_t s, obj_no_t * &array)
 {
-int count = 0;
-for (int n = 0; n < NumLineDefs; n++)
-   if (   is_sidedef (LineDefs[n].sidedef1)
-          && SideDefs[LineDefs[n].sidedef1].sector == s
-       || is_sidedef (LineDefs[n].sidedef2)
-          && SideDefs[LineDefs[n].sidedef2].sector == s)
-      count++;
-if (count > 0)
-   {
-   array = new obj_no_t[count];
-   count = 0;
-   for (int n = 0; n < NumLineDefs; n++)
-      if (   is_sidedef (LineDefs[n].sidedef1)
-	     && SideDefs[LineDefs[n].sidedef1].sector == s
-	  || is_sidedef (LineDefs[n].sidedef2)
-	     && SideDefs[LineDefs[n].sidedef2].sector == s)
-	 array[count++] = n;
-   }
-return count;
+    int count = 0;
+    for (int n = 0; n < NumLineDefs; n++)
+	if (is_sidedef(LineDefs[n].sidedef1)
+	    && SideDefs[LineDefs[n].sidedef1].sector == s
+	    || is_sidedef(LineDefs[n].sidedef2)
+	    && SideDefs[LineDefs[n].sidedef2].sector == s)
+	    count++;
+    if (count > 0)
+    {
+	array = new obj_no_t[count];
+	count = 0;
+	for (int n = 0; n < NumLineDefs; n++)
+	    if (is_sidedef(LineDefs[n].sidedef1)
+		&& SideDefs[LineDefs[n].sidedef1].sector == s
+		|| is_sidedef(LineDefs[n].sidedef2)
+		&& SideDefs[LineDefs[n].sidedef2].sector == s)
+		array[count++] = n;
+    }
+    return count;
 }
-
-
--- a/src/s_linedefs.h	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/s_linedefs.h	Sat Sep 24 14:16:04 2011 +0300
@@ -7,8 +7,6 @@
 class bitvec_c;
 
 
-bitvec_c *linedefs_of_sector (obj_no_t s);
-bitvec_c *linedefs_of_sectors (SelPtr list);
-int linedefs_of_sector (obj_no_t s, obj_no_t *&array);
-
-
+bitvec_c *linedefs_of_sector(obj_no_t s);
+bitvec_c *linedefs_of_sectors(SelPtr list);
+int linedefs_of_sector(obj_no_t s, obj_no_t * &array);
--- a/src/s_merge.cc	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/s_merge.cc	Sat Sep 24 14:16:04 2011 +0300
@@ -40,31 +40,31 @@
    merge two or more Sectors into one
 */
 
-void MergeSectors (SelPtr *slist) /* SWAP! */
+void MergeSectors(SelPtr * slist)	/* SWAP! */
 {
-SelPtr cur;
-int    n, olds, news;
+    SelPtr cur;
+    int n, olds, news;
 
 /* save the first Sector number */
-news = (*slist)->objnum;
-UnSelectObject (slist, news);
+    news = (*slist)->objnum;
+    UnSelectObject(slist, news);
 
 /* change all SideDefs references to the other Sectors */
-for (cur = *slist; cur; cur = cur->next)
-{
-   olds = cur->objnum;
-   for (n = 0; n < NumSideDefs; n++)
-   {
-      if (SideDefs[n].sector == olds)
-	 SideDefs[n].sector = news;
-   }
-}
+    for (cur = *slist; cur; cur = cur->next)
+    {
+	olds = cur->objnum;
+	for (n = 0; n < NumSideDefs; n++)
+	{
+	    if (SideDefs[n].sector == olds)
+		SideDefs[n].sector = news;
+	}
+    }
 
 /* delete the Sectors */
-DeleteObjects (OBJ_SECTORS, slist);
+    DeleteObjects(OBJ_SECTORS, slist);
 
 /* the returned list contains only the first Sector */
-SelectObject (slist, news);
+    SelectObject(slist, news);
 }
 
 
@@ -73,51 +73,49 @@
    delete one or several two-sided LineDefs and join the two Sectors
 */
 
-void DeleteLineDefsJoinSectors (SelPtr *ldlist) /* SWAP! */
+void DeleteLineDefsJoinSectors(SelPtr * ldlist)	/* SWAP! */
 {
-SelPtr cur, slist;
-int    sd1, sd2;
-int    s1, s2;
-char   msg[80];
+    SelPtr cur, slist;
+    int sd1, sd2;
+    int s1, s2;
+    char msg[80];
 
 /* first, do the tests for all LineDefs */
-for (cur = *ldlist; cur; cur = cur->next)
-   {
-   sd1 = LineDefs[cur->objnum].sidedef1;
-   sd2 = LineDefs[cur->objnum].sidedef2;
-   if (sd1 < 0 || sd2 < 0)
-      {
-      Beep ();
-      sprintf (msg, "ERROR: Linedef #%d has only one side", cur->objnum);
-      Notify (-1, -1, msg, NULL);
-      return;
-      }
-   s1 = SideDefs[sd1].sector;
-   s2 = SideDefs[sd2].sector;
-   if (s1 < 0 || s2 < 0)
-      {
-      Beep ();
-      sprintf (msg, "ERROR: Linedef #%d has two sides, but one", cur->objnum);
-      Notify (-1, -1, msg, "side is not bound to any sector");
-      return;
-      }
-   }
+    for (cur = *ldlist; cur; cur = cur->next)
+    {
+	sd1 = LineDefs[cur->objnum].sidedef1;
+	sd2 = LineDefs[cur->objnum].sidedef2;
+	if (sd1 < 0 || sd2 < 0)
+	{
+	    Beep();
+	    sprintf(msg, "ERROR: Linedef #%d has only one side", cur->objnum);
+	    Notify(-1, -1, msg, NULL);
+	    return;
+	}
+	s1 = SideDefs[sd1].sector;
+	s2 = SideDefs[sd2].sector;
+	if (s1 < 0 || s2 < 0)
+	{
+	    Beep();
+	    sprintf(msg, "ERROR: Linedef #%d has two sides, but one",
+		    cur->objnum);
+	    Notify(-1, -1, msg, "side is not bound to any sector");
+	    return;
+	}
+    }
 
 /* then join the Sectors and delete the LineDefs */
-for (cur = *ldlist; cur; cur = cur->next)
-   {
-   sd1 = LineDefs[cur->objnum].sidedef1;
-   sd2 = LineDefs[cur->objnum].sidedef2;
-   s1 = SideDefs[sd1].sector;
-   s2 = SideDefs[sd2].sector;
-   slist = NULL;
-   SelectObject (&slist, s2);
-   SelectObject (&slist, s1);
-   MergeSectors (&slist);
-   ForgetSelection (&slist);
-   }
-DeleteObjects (OBJ_LINEDEFS, ldlist);
+    for (cur = *ldlist; cur; cur = cur->next)
+    {
+	sd1 = LineDefs[cur->objnum].sidedef1;
+	sd2 = LineDefs[cur->objnum].sidedef2;
+	s1 = SideDefs[sd1].sector;
+	s2 = SideDefs[sd2].sector;
+	slist = NULL;
+	SelectObject(&slist, s2);
+	SelectObject(&slist, s1);
+	MergeSectors(&slist);
+	ForgetSelection(&slist);
+    }
+    DeleteObjects(OBJ_LINEDEFS, ldlist);
 }
-
-
-
--- a/src/s_misc.cc	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/s_misc.cc	Sat Sep 24 14:16:04 2011 +0300
@@ -44,25 +44,25 @@
    Distribute sector floor heights
 */
 
-void DistributeSectorFloors (SelPtr obj) /* SWAP! */
+void DistributeSectorFloors(SelPtr obj)	/* SWAP! */
 {
-SelPtr cur;
-int    n, num, floor1h, floor2h;
+    SelPtr cur;
+    int n, num, floor1h, floor2h;
 
-num = 0;
-for (cur = obj; cur->next; cur = cur->next)
-   num++;
+    num = 0;
+    for (cur = obj; cur->next; cur = cur->next)
+	num++;
 
-floor1h = Sectors[obj->objnum].floorh;
-floor2h = Sectors[cur->objnum].floorh;
+    floor1h = Sectors[obj->objnum].floorh;
+    floor2h = Sectors[cur->objnum].floorh;
 
-n = 0;
-for (cur = obj; cur; cur = cur->next)
-   {
-   Sectors[cur->objnum].floorh = floor1h + n * (floor2h - floor1h) / num;
-   n++;
-   }
-MadeChanges = 1;
+    n = 0;
+    for (cur = obj; cur; cur = cur->next)
+    {
+	Sectors[cur->objnum].floorh = floor1h + n * (floor2h - floor1h) / num;
+	n++;
+    }
+    MadeChanges = 1;
 }
 
 
@@ -71,25 +71,25 @@
    Distribute sector ceiling heights
 */
 
-void DistributeSectorCeilings (SelPtr obj) /* SWAP! */
+void DistributeSectorCeilings(SelPtr obj)	/* SWAP! */
 {
-SelPtr cur;
-int    n, num, ceil1h, ceil2h;
+    SelPtr cur;
+    int n, num, ceil1h, ceil2h;
 
-num = 0;
-for (cur = obj; cur->next; cur = cur->next)
-   num++;
+    num = 0;
+    for (cur = obj; cur->next; cur = cur->next)
+	num++;
 
-ceil1h = Sectors[obj->objnum].ceilh;
-ceil2h = Sectors[cur->objnum].ceilh;
+    ceil1h = Sectors[obj->objnum].ceilh;
+    ceil2h = Sectors[cur->objnum].ceilh;
 
-n = 0;
-for (cur = obj; cur; cur = cur->next)
-   {
-   Sectors[cur->objnum].ceilh = ceil1h + n * (ceil2h - ceil1h) / num;
-   n++;
-   }
-MadeChanges = 1;
+    n = 0;
+    for (cur = obj; cur; cur = cur->next)
+    {
+	Sectors[cur->objnum].ceilh = ceil1h + n * (ceil2h - ceil1h) / num;
+	n++;
+    }
+    MadeChanges = 1;
 }
 
 
@@ -97,38 +97,40 @@
    Raise or lower sectors
 */
 
-void RaiseOrLowerSectors (SelPtr obj)
+void RaiseOrLowerSectors(SelPtr obj)
 {
-SelPtr cur;
-int  x0;          // left hand (x) window start
-int  y0;          // top (y) window start
-int  key;         // holds value returned by InputInteger
-int  delta = 0;   // user input for delta
+    SelPtr cur;
+    int x0;			// left hand (x) window start
+    int y0;			// top (y) window start
+    int key;			// holds value returned by InputInteger
+    int delta = 0;		// user input for delta
 
 
-x0 = (ScrMaxX - 25 - 44 * FONTW) / 2;
-y0 = (ScrMaxY - 7 * FONTH) / 2;
-DrawScreenBox3D (x0, y0, x0 + 25 + 44 * FONTW, y0 + 7 * FONTH);
-set_colour (WHITE);
-DrawScreenText (x0+10, y0 + FONTH,     "Enter number of units to raise the ceilings");
-DrawScreenText (x0+10, y0 + 2 * FONTH, "and floors of selected sectors by.");
-DrawScreenText (x0+10, y0 + 3 * FONTH, "A negative number lowers them.");
-while (1)
-  {
-  key = InputInteger (x0+10, y0 + 5 * FONTH, &delta, -32768, 32767);
-  if (key == YK_RETURN || key == YK_ESC)
-    break;
-  Beep ();
-  }
-if (key == YK_ESC)
-  return;
+    x0 = (ScrMaxX - 25 - 44 * FONTW) / 2;
+    y0 = (ScrMaxY - 7 * FONTH) / 2;
+    DrawScreenBox3D(x0, y0, x0 + 25 + 44 * FONTW, y0 + 7 * FONTH);
+    set_colour(WHITE);
+    DrawScreenText(x0 + 10, y0 + FONTH,
+		   "Enter number of units to raise the ceilings");
+    DrawScreenText(x0 + 10, y0 + 2 * FONTH,
+		   "and floors of selected sectors by.");
+    DrawScreenText(x0 + 10, y0 + 3 * FONTH, "A negative number lowers them.");
+    while (1)
+    {
+	key = InputInteger(x0 + 10, y0 + 5 * FONTH, &delta, -32768, 32767);
+	if (key == YK_RETURN || key == YK_ESC)
+	    break;
+	Beep();
+    }
+    if (key == YK_ESC)
+	return;
 
-for (cur = obj; cur != NULL; cur = cur->next)
-  {
-  Sectors[cur->objnum].ceilh += delta;
-  Sectors[cur->objnum].floorh += delta;
-  }
-MadeChanges = 1;
+    for (cur = obj; cur != NULL; cur = cur->next)
+    {
+	Sectors[cur->objnum].ceilh += delta;
+	Sectors[cur->objnum].floorh += delta;
+    }
+    MadeChanges = 1;
 }
 
 
@@ -136,79 +138,80 @@
    Brighten or darken sectors
 */
 
-void BrightenOrDarkenSectors (SelPtr obj)
+void BrightenOrDarkenSectors(SelPtr obj)
 {
-SelPtr cur;
-int  x0;          // left hand (x) window start
-int  y0;          // top (y) window start
-int  key;         // holds value returned by InputInteger
-int  delta = 0;   // user input for delta
+    SelPtr cur;
+    int x0;			// left hand (x) window start
+    int y0;			// top (y) window start
+    int key;			// holds value returned by InputInteger
+    int delta = 0;		// user input for delta
 
 
-x0 = (ScrMaxX - 25 - 44 * FONTW) / 2;
-y0 = (ScrMaxY - 7 * FONTH) / 2;
-DrawScreenBox3D (x0, y0, x0 + 25 + 44 * FONTW, y0 + 7 * FONTH);
-set_colour (WHITE);
-DrawScreenText (x0+10, y0 + FONTH,     "Enter number of units to brighten");
-DrawScreenText (x0+10, y0 + 2 * FONTH, "the selected sectors by.");
-DrawScreenText (x0+10, y0 + 3 * FONTH, "A negative number darkens them.");
-while (1)
-  {
-  key = InputInteger (x0+10, y0 + 5 * FONTH, &delta, -255, 255);
-  if (key == YK_RETURN || key == YK_ESC)
-    break;
-  Beep ();
-  }
-if (key == YK_ESC)
-  return;
+    x0 = (ScrMaxX - 25 - 44 * FONTW) / 2;
+    y0 = (ScrMaxY - 7 * FONTH) / 2;
+    DrawScreenBox3D(x0, y0, x0 + 25 + 44 * FONTW, y0 + 7 * FONTH);
+    set_colour(WHITE);
+    DrawScreenText(x0 + 10, y0 + FONTH, "Enter number of units to brighten");
+    DrawScreenText(x0 + 10, y0 + 2 * FONTH, "the selected sectors by.");
+    DrawScreenText(x0 + 10, y0 + 3 * FONTH,
+		   "A negative number darkens them.");
+    while (1)
+    {
+	key = InputInteger(x0 + 10, y0 + 5 * FONTH, &delta, -255, 255);
+	if (key == YK_RETURN || key == YK_ESC)
+	    break;
+	Beep();
+    }
+    if (key == YK_ESC)
+	return;
 
-for (cur = obj; cur != NULL; cur = cur->next)
-  {
-  int light;
-  light = Sectors[cur->objnum].light + delta;
-  light = y_max (light, 0);
-  light = y_min (light, 255);
-  Sectors[cur->objnum].light = light;
-  }
-MadeChanges = 1;
+    for (cur = obj; cur != NULL; cur = cur->next)
+    {
+	int light;
+	light = Sectors[cur->objnum].light + delta;
+	light = y_max(light, 0);
+	light = y_min(light, 255);
+	Sectors[cur->objnum].light = light;
+    }
+    MadeChanges = 1;
 }
 
 
-static int find_linedef_for_area (int x, int y, int& side)
+static int find_linedef_for_area(int x, int y, int &side)
 {
-   int n, m, curx;
-   int best_match = -1;
+    int n, m, curx;
+    int best_match = -1;
 
-   curx = 32767;  // Oh yes, one more hard-coded constant!
+    curx = 32767;		// Oh yes, one more hard-coded constant!
 
-   for (n = 0; n < NumLineDefs; n++)
-      if ((Vertices[LineDefs[n].start].y > y)
-       != (Vertices[LineDefs[n].end].y > y))
-      {
-         int lx0 = Vertices[LineDefs[n].start].x;
-         int ly0 = Vertices[LineDefs[n].start].y;
-         int lx1 = Vertices[LineDefs[n].end].x;
-         int ly1 = Vertices[LineDefs[n].end].y;
-         m = lx0 + (int) ((long) (y - ly0) * (long) (lx1 - lx0)
-                                           / (long) (ly1 - ly0));
-         if (m >= x && m < curx)
-         {
-            curx = m;
-            best_match = n;
-         }
-      }
+    for (n = 0; n < NumLineDefs; n++)
+	if ((Vertices[LineDefs[n].start].y > y)
+	    != (Vertices[LineDefs[n].end].y > y))
+	{
+	    int lx0 = Vertices[LineDefs[n].start].x;
+	    int ly0 = Vertices[LineDefs[n].start].y;
+	    int lx1 = Vertices[LineDefs[n].end].x;
+	    int ly1 = Vertices[LineDefs[n].end].y;
+	    m = lx0 + (int) ((long) (y - ly0) * (long) (lx1 - lx0)
+			     / (long) (ly1 - ly0));
+	    if (m >= x && m < curx)
+	    {
+		curx = m;
+		best_match = n;
+	    }
+	}
 
-   /* now look if this linedef has a sidedef bound to one sector */
-   if (best_match < 0)
-      return OBJ_NO_NONE;
+    /* now look if this linedef has a sidedef bound to one sector */
+    if (best_match < 0)
+	return OBJ_NO_NONE;
 
-   if (Vertices[LineDefs[best_match].start].y
-     > Vertices[LineDefs[best_match].end].y)
-      side = 1;
-   else
-      side = 2;
+    if (Vertices[LineDefs[best_match].start].y
+	> Vertices[LineDefs[best_match].end].y)
+	side = 1;
+    else
+	side = 2;
 
-   return best_match;
+    return best_match;
 }
 
 /*
@@ -218,35 +221,35 @@
  */
 #define DEBUG_ANGLE  0
 
-static double angle_between_linedefs (int A, int B, int C)
+static double angle_between_linedefs(int A, int B, int C)
 {
-   int a_dx = Vertices[B].x - Vertices[A].x;
-   int a_dy = Vertices[B].y - Vertices[A].y;
-   
-   int c_dx = Vertices[B].x - Vertices[C].x;
-   int c_dy = Vertices[B].y - Vertices[C].y;
-   
-   double AB_angle = (a_dx == 0) ? (a_dy >= 0 ? 90 : -90) :
-      atan2 (a_dy, a_dx) * 180 / M_PI;
+    int a_dx = Vertices[B].x - Vertices[A].x;
+    int a_dy = Vertices[B].y - Vertices[A].y;
+
+    int c_dx = Vertices[B].x - Vertices[C].x;
+    int c_dy = Vertices[B].y - Vertices[C].y;
+
+    double AB_angle = (a_dx == 0) ? (a_dy >= 0 ? 90 : -90) :
+	atan2(a_dy, a_dx) * 180 / M_PI;
 
-   double CB_angle = (c_dx == 0) ? (c_dy >= 0 ? 90 : -90) :
-      atan2 (c_dy, c_dx) * 180 / M_PI;
+    double CB_angle = (c_dx == 0) ? (c_dy >= 0 ? 90 : -90) :
+	atan2(c_dy, c_dx) * 180 / M_PI;
 
-   double result = CB_angle - AB_angle;
+    double result = CB_angle - AB_angle;
 
-   if (result >= 360)
-      result -= 360;
-   
-   while (result < 0)
-      result += 360;
+    if (result >= 360)
+	result -= 360;
+
+    while (result < 0)
+	result += 360;
 
 #if (DEBUG_ANGLE)
-   fprintf(stderr, "ANGLE %1.6f  (%d,%d) -> (%d,%d) -> (%d,%d)\n",
-      result, Vertices[A].x, Vertices[A].y,
-      Vertices[B].x, Vertices[B].y, Vertices[C].x, Vertices[C].y);
+    fprintf(stderr, "ANGLE %1.6f  (%d,%d) -> (%d,%d) -> (%d,%d)\n",
+	    result, Vertices[A].x, Vertices[A].y,
+	    Vertices[B].x, Vertices[B].y, Vertices[C].x, Vertices[C].y);
 #endif
 
-   return result;
+    return result;
 }
 
 /*
@@ -258,188 +261,189 @@
  */
 #define DEBUG_PATH  0
 
-static int select_sides_in_closed_path (bitvec_c& ld_side1,
-    bitvec_c& ld_side2, int line, int side)
+static int select_sides_in_closed_path(bitvec_c & ld_side1,
+				       bitvec_c & ld_side2, int line,
+				       int side)
 {
-   int cur_vert, prev_vert, final_vert;
-   
-   if (side == 1)
-   {
-      ld_side1.set (line);
-      cur_vert = LineDefs[line].end;
-      prev_vert = final_vert = LineDefs[line].start;
-   }
-   else
-   {
-      ld_side2.set (line);
-      cur_vert = LineDefs[line].start;
-      prev_vert = final_vert = LineDefs[line].end;
-   }
+    int cur_vert, prev_vert, final_vert;
+
+    if (side == 1)
+    {
+	ld_side1.set(line);
+	cur_vert = LineDefs[line].end;
+	prev_vert = final_vert = LineDefs[line].start;
+    }
+    else
+    {
+	ld_side2.set(line);
+	cur_vert = LineDefs[line].start;
+	prev_vert = final_vert = LineDefs[line].end;
+    }
 
 #if (DEBUG_PATH)
-      fprintf(stderr, "PATH: line %d  side %d  cur %d  final %d\n",
-         line, side, cur_vert, final_vert);
+    fprintf(stderr, "PATH: line %d  side %d  cur %d  final %d\n",
+	    line, side, cur_vert, final_vert);
 #endif
 
-   while (cur_vert != final_vert)
-   {
-      int next_line = OBJ_NO_NONE;
-      int next_vert = OBJ_NO_NONE;
-      int next_side;
-      double best_angle = 999;
+    while (cur_vert != final_vert)
+    {
+	int next_line = OBJ_NO_NONE;
+	int next_vert = OBJ_NO_NONE;
+	int next_side;
+	double best_angle = 999;
 
-      // Look for the next linedef in the path.  It's the linedef that
-      // uses the current vertex and is not the current one.
+	// Look for the next linedef in the path.  It's the linedef that
+	// uses the current vertex and is not the current one.
 
-      for (int n = 0; n < NumLineDefs; n++)
-      {
-         if (n == line)
-            continue;
+	for (int n = 0; n < NumLineDefs; n++)
+	{
+	    if (n == line)
+		continue;
 
-         int other_vert;
-         int which_side;
+	    int other_vert;
+	    int which_side;
 
-         if (LineDefs[n].start == cur_vert)
-         {
-            other_vert = LineDefs[n].end;
-            which_side = 1;
-         }
-         else if (LineDefs[n].end == cur_vert)
-         {
-            other_vert = LineDefs[n].start;
-            which_side = 2;
-         }
-         else
-            continue;
+	    if (LineDefs[n].start == cur_vert)
+	    {
+		other_vert = LineDefs[n].end;
+		which_side = 1;
+	    }
+	    else if (LineDefs[n].end == cur_vert)
+	    {
+		other_vert = LineDefs[n].start;
+		which_side = 2;
+	    }
+	    else
+		continue;
+
+	    // found adjoining linedef
 
-         // found adjoining linedef
-         
-         double angle = angle_between_linedefs (prev_vert, cur_vert,
-            other_vert);
-         
-         if (! is_obj (next_line) || angle < best_angle)
-         {
-            next_line = n;
-            next_vert = other_vert;
-            next_side = which_side;
-            
-            best_angle = angle;
-         }
+	    double angle = angle_between_linedefs(prev_vert, cur_vert,
+						  other_vert);
+
+	    if (!is_obj(next_line) || angle < best_angle)
+	    {
+		next_line = n;
+		next_vert = other_vert;
+		next_side = which_side;
 
-         // Continue the search
-      }
- 
-      line = next_line;
-      side = next_side;
+		best_angle = angle;
+	    }
+
+	    // Continue the search
+	}
+
+	line = next_line;
+	side = next_side;
 
 #if (DEBUG_PATH)
-      fprintf(stderr, "PATH NEXT: line %d  side %d  vert %d  angle %1.6f\n",
-         line, side, next_vert, best_angle);
+	fprintf(stderr, "PATH NEXT: line %d  side %d  vert %d  angle %1.6f\n",
+		line, side, next_vert, best_angle);
 #endif
 
-      // None ?  Path cannot be closed
-      if (! is_obj (line))
-         return 0;
+	// None ?  Path cannot be closed
+	if (!is_obj(line))
+	    return 0;
 
-      // Line already seen ?  Under normal circumstances this won't
-      // happen, but it _can_ happen and indicates a non-closed
-      // structure
-      if (ld_side1.get (line) || ld_side2.get (line))
-         return 0;
+	// Line already seen ?  Under normal circumstances this won't
+	// happen, but it _can_ happen and indicates a non-closed
+	// structure
+	if (ld_side1.get(line) || ld_side2.get(line))
+	    return 0;
 
-      if (side == 1)
-         ld_side1.set (line);
-      else
-         ld_side2.set (line);
-       
-      prev_vert = cur_vert;
-      cur_vert = next_vert;
-   }
+	if (side == 1)
+	    ld_side1.set(line);
+	else
+	    ld_side2.set(line);
+
+	prev_vert = cur_vert;
+	cur_vert = next_vert;
+    }
 
 #if (DEBUG_PATH)
-      fprintf(stderr, "PATH CLOSED !\n");
+    fprintf(stderr, "PATH CLOSED !\n");
 #endif
 
-   return 1;
+    return 1;
 }
 
 /*
    update the side on a single linedef, using the given sector
    reference.  Will create a new sidedef if necessary.
  */
-static void super_set_sector_on_side (int line, wad_sdn_t& side,
-   wad_sdn_t& other, int side_no, int sector)
+static void super_set_sector_on_side(int line, wad_sdn_t & side,
+				     wad_sdn_t & other, int side_no,
+				     int sector)
 {
-   if (is_obj (side) && SideDefs[side].sector == sector)
-   {
-      // there was no change.
-      return;
-   }
-   
-   int must_flip = 0;
+    if (is_obj(side) && SideDefs[side].sector == sector)
+    {
+	// there was no change.
+	return;
+    }
+
+    int must_flip = 0;
 
-   if (! is_obj (side))
-   {
-      // if we're adding a sidedef to a line that has no sides, and
-      // the sidedef would be the 2nd one, then flip the linedef.
-      // Thus we don't end up with invalid lines -- i.e. ones with a
-      // left side but no right side.
+    if (!is_obj(side))
+    {
+	// if we're adding a sidedef to a line that has no sides, and
+	// the sidedef would be the 2nd one, then flip the linedef.
+	// Thus we don't end up with invalid lines -- i.e. ones with a
+	// left side but no right side.
 
-      if (! is_obj (other) && side_no == 2)
-         must_flip = 1;
+	if (!is_obj(other) && side_no == 2)
+	    must_flip = 1;
 
-      InsertObject (OBJ_SIDEDEFS, OBJ_NO_NONE, 0, 0);
-      side = NumSideDefs - 1;
+	InsertObject(OBJ_SIDEDEFS, OBJ_NO_NONE, 0, 0);
+	side = NumSideDefs - 1;
 
-      // if we're adding a second side to the linedef, clear out some
-      // of the properties that aren't needed anymore: middle texture,
-      // two-sided flag, and impassible flag.
-      
-      if (is_obj (other))
-      {
-         strncpy (SideDefs[side].tex3,  "-", WAD_TEX_NAME);
-         strncpy (SideDefs[other].tex3, "-", WAD_TEX_NAME);
+	// if we're adding a second side to the linedef, clear out some
+	// of the properties that aren't needed anymore: middle texture,
+	// two-sided flag, and impassible flag.
 
-         LineDefs[line].flags |=  4;  // Set the 2S bit
-         LineDefs[line].flags &= ~1;  // Clear the Im bit
-      }
-   }
+	if (is_obj(other))
+	{
+	    strncpy(SideDefs[side].tex3, "-", WAD_TEX_NAME);
+	    strncpy(SideDefs[other].tex3, "-", WAD_TEX_NAME);
+
+	    LineDefs[line].flags |= 4;	// Set the 2S bit
+	    LineDefs[line].flags &= ~1;	// Clear the Im bit
+	}
+    }
 
-   SideDefs[side].sector = sector;
-   
-   if (must_flip)
-   {
-      int temp = LineDefs[line].start;
-      LineDefs[line].start = LineDefs[line].end;
-      LineDefs[line].end = temp;
+    SideDefs[side].sector = sector;
+
+    if (must_flip)
+    {
+	int temp = LineDefs[line].start;
+	LineDefs[line].start = LineDefs[line].end;
+	LineDefs[line].end = temp;
 
-      temp = side; 
-      side = other; 
-      other = temp;
-   }
+	temp = side;
+	side = other;
+	other = temp;
+    }
 
-   MadeChanges = 1;
-   MadeMapChanges = 1;
+    MadeChanges = 1;
+    MadeMapChanges = 1;
 }
 
-static int super_find_sector_model (bitvec_c& ld_side1,
-    bitvec_c& ld_side2)
+static int super_find_sector_model(bitvec_c & ld_side1, bitvec_c & ld_side2)
 {
-   for (int line=0; line < NumLineDefs; line++)
-   {
-      int side1 = LineDefs[line].sidedef1;
-      int side2 = LineDefs[line].sidedef2;
+    for (int line = 0; line < NumLineDefs; line++)
+    {
+	int side1 = LineDefs[line].sidedef1;
+	int side2 = LineDefs[line].sidedef2;
 
-      if (ld_side1.get (line))
-         if (is_obj (side2))
-            return SideDefs[side2].sector;
+	if (ld_side1.get(line))
+	    if (is_obj(side2))
+		return SideDefs[side2].sector;
 
-      if (ld_side2.get (line))
-         if (is_obj (side1))
-            return SideDefs[side1].sector;
-   }
+	if (ld_side2.get(line))
+	    if (is_obj(side1))
+		return SideDefs[side1].sector;
+    }
 
-   return OBJ_NO_NONE;
+    return OBJ_NO_NONE;
 }
 
 
@@ -455,58 +459,58 @@
    -AJA- 2001-05-08
  */
 
-void SuperSectorSelector (int map_x, int map_y, int new_sec)
+void SuperSectorSelector(int map_x, int map_y, int new_sec)
 {
-   int line, side;
-   char msg_buf[200];
+    int line, side;
+    char msg_buf[200];
 
-   line = find_linedef_for_area (map_x, map_y, side);
+    line = find_linedef_for_area(map_x, map_y, side);
 
-   if (! is_obj (line))
-   {
-      Beep ();
-      sprintf (msg_buf, "Chosen area is not closed");
-      Notify (-1, -1, msg_buf, NULL);
-      return;
-   }
+    if (!is_obj(line))
+    {
+	Beep();
+	sprintf(msg_buf, "Chosen area is not closed");
+	Notify(-1, -1, msg_buf, NULL);
+	return;
+    }
 
-   bitvec_c ld_side1 (NumLineDefs);
-   bitvec_c ld_side2 (NumLineDefs);
-   
-   int closed = select_sides_in_closed_path (ld_side1, ld_side2,
-      line, side);
+    bitvec_c ld_side1(NumLineDefs);
+    bitvec_c ld_side2(NumLineDefs);
+
+    int closed = select_sides_in_closed_path(ld_side1, ld_side2,
+					     line, side);
 
-   if (! closed)
-   {
-      Beep ();
-      sprintf (msg_buf, "Area chosen is not closed");
-      Notify (-1, -1, msg_buf, NULL);
-      return;
-   }
+    if (!closed)
+    {
+	Beep();
+	sprintf(msg_buf, "Area chosen is not closed");
+	Notify(-1, -1, msg_buf, NULL);
+	return;
+    }
+
+    // -AJA- FIXME: look for "islands", closed linedef paths that lie
+    // completely inside the area, i.e. not connected to the main path.
+    // Example: the two pillars at the start of MAP01 of DOOM 2.  See
+    // GetOppositeSector() and the end of SplitSector() for a possible
+    // algorithm.
 
-   // -AJA- FIXME: look for "islands", closed linedef paths that lie
-   // completely inside the area, i.e. not connected to the main path.
-   // Example: the two pillars at the start of MAP01 of DOOM 2.  See
-   // GetOppositeSector() and the end of SplitSector() for a possible
-   // algorithm.
-   
-   if (! is_obj (new_sec))
-   {
-      int model = super_find_sector_model (ld_side1, ld_side2);
-      InsertObject (OBJ_SECTORS, model, 0, 0);
-      new_sec = NumSectors - 1;
-   }
-   
-   for (line=0; line < NumLineDefs; line++)
-   {
-      if (ld_side1.get (line))
-         super_set_sector_on_side (line, LineDefs[line].sidedef1,
-            LineDefs[line].sidedef2, 1, new_sec);
+    if (!is_obj(new_sec))
+    {
+	int model = super_find_sector_model(ld_side1, ld_side2);
+	InsertObject(OBJ_SECTORS, model, 0, 0);
+	new_sec = NumSectors - 1;
+    }
 
-      else if (ld_side2.get (line))
-         super_set_sector_on_side (line, LineDefs[line].sidedef2,
-            LineDefs[line].sidedef1, 2, new_sec);
-   }
+    for (line = 0; line < NumLineDefs; line++)
+    {
+	if (ld_side1.get(line))
+	    super_set_sector_on_side(line, LineDefs[line].sidedef1,
+				     LineDefs[line].sidedef2, 1, new_sec);
+
+	else if (ld_side2.get(line))
+	    super_set_sector_on_side(line, LineDefs[line].sidedef2,
+				     LineDefs[line].sidedef1, 2, new_sec);
+    }
 }
 
 /* end of file */
--- a/src/s_prop.cc	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/s_prop.cc	Sat Sep 24 14:16:04 2011 +0300
@@ -42,15 +42,13 @@
 #include "selectn.h"
 
 
-class Menu_data_st : public Menu_data
+class Menu_data_st:public Menu_data
 {
-  public :
-    Menu_data_st (al_llist_t *list);
-    virtual size_t nitems () const;
+    public:Menu_data_st(al_llist_t * list);
+    virtual size_t nitems() const;
     virtual const char *operator[] (size_t n) const;
 
-  private :
-    mutable char buf[100];
+      private: mutable char buf[100];
     al_llist_t *list;
 };
 
@@ -58,201 +56,201 @@
 /*
  *	Menu_data_st::Menu_data_st - ctor
  */
-Menu_data_st::Menu_data_st (al_llist_t *list) : list (list)
+Menu_data_st::Menu_data_st(al_llist_t * list):list(list)
 {
-  al_lrewind (this->list);
+    al_lrewind(this->list);
 }
 
 
 /*
  *	Menu_data_st::nitems - return the number of items
  */
-size_t Menu_data_st::nitems () const
+size_t Menu_data_st::nitems() const
 {
-  return al_lcount (list);
+    return al_lcount(list);
 }
 
 
 /*
  *	Menu_data_st::operator[] - return the nth item
  */
-const char *Menu_data_st::operator[] (size_t n) const
-{
-  if (al_lseek (list, n, SEEK_SET) != 0)
-  {
-    sprintf (buf, "BUG: al_lseek(%p, %lu): %s",
-      (void *) list, 
-      (unsigned long) n,
-      al_astrerror (al_aerrno));
-    return buf;
-  }
-  const stdef_t *ptr = (const stdef_t *) al_lptr (list);
-  if (ptr == NULL)
-    sprintf (buf, "BUG: al_lptr(%p): %s",
-      (void *) list,
-      al_astrerror (al_aerrno));
-  else
-    sprintf (buf, "%2d - %.70s", ptr->number, ptr->longdesc);
-  return buf;
-}
+const char *Menu_data_st::operator[] (size_t n)
+     const
+     {
+	 if (al_lseek(list, n, SEEK_SET) != 0)
+	 {
+	     sprintf(buf, "BUG: al_lseek(%p, %lu): %s",
+		     (void *) list,
+		     (unsigned long) n, al_astrerror(al_aerrno));
+	     return buf;
+	 }
+	 const stdef_t *ptr = (const stdef_t *) al_lptr(list);
+	 if (ptr == NULL)
+	     sprintf(buf, "BUG: al_lptr(%p): %s",
+		     (void *) list, al_astrerror(al_aerrno));
+	 else
+	     sprintf(buf, "%2d - %.70s", ptr->number, ptr->longdesc);
+	 return buf;
+     }
 
 
 /*
  *	SectorProperties
  *	Sector properties "dialog"
  */
-void SectorProperties (int x0, int y0, SelPtr obj)
+void SectorProperties(int x0, int y0, SelPtr obj)
 {
-  char  *menustr[30];
-  char   texname[WAD_FLAT_NAME + 1];
-  int    n, val;
-  SelPtr cur;
-  int    subwin_y0;
+    char *menustr[30];
+    char texname[WAD_FLAT_NAME + 1];
+    int n, val;
+    SelPtr cur;
+    int subwin_y0;
 
-  for (n = 0; n < 8; n++)
-    menustr[n] = (char *) GetMemory (60);
-  sprintf (menustr[7], "Edit sector #%d", obj->objnum);
-  sprintf (menustr[0], "Change floor height     (Current: %d)",
-	  Sectors[obj->objnum].floorh);
-  sprintf (menustr[1], "Change ceiling height   (Current: %d)",
-	  Sectors[obj->objnum].ceilh);
-  sprintf (menustr[2], "Change floor texture    (Current: %.*s)",
-	  (int) WAD_FLAT_NAME, Sectors[obj->objnum].floort);
-  sprintf (menustr[3], "Change ceiling texture  (Current: %.*s)",
-	  (int) WAD_FLAT_NAME, Sectors[obj->objnum].ceilt);
-  sprintf (menustr[4], "Change light level      (Current: %d)",
-	  Sectors[obj->objnum].light);
-  sprintf (menustr[5], "Change type             (Current: %d)",
-	  Sectors[obj->objnum].special);
-  sprintf (menustr[6], "Change linedef tag      (Current: %d)",
-	  Sectors[obj->objnum].tag);
-  val = vDisplayMenu (x0, y0, menustr[7],
-    menustr[0], YK_, 0,
-    menustr[1], YK_, 0,
-    menustr[2], YK_, 0,
-    menustr[3], YK_, 0,
-    menustr[4], YK_, 0,
-    menustr[5], YK_, 0,
-    menustr[6], YK_, 0,
-    NULL);
-  for (n = 0; n < 8; n++)
-    FreeMemory (menustr[n]);
-  subwin_y0 = y0 + BOX_BORDER + (2 + val) * FONTH;
-  switch (val)
-  {
+    for (n = 0; n < 8; n++)
+	menustr[n] = (char *) GetMemory(60);
+    sprintf(menustr[7], "Edit sector #%d", obj->objnum);
+    sprintf(menustr[0], "Change floor height     (Current: %d)",
+	    Sectors[obj->objnum].floorh);
+    sprintf(menustr[1], "Change ceiling height   (Current: %d)",
+	    Sectors[obj->objnum].ceilh);
+    sprintf(menustr[2], "Change floor texture    (Current: %.*s)",
+	    (int) WAD_FLAT_NAME, Sectors[obj->objnum].floort);
+    sprintf(menustr[3], "Change ceiling texture  (Current: %.*s)",
+	    (int) WAD_FLAT_NAME, Sectors[obj->objnum].ceilt);
+    sprintf(menustr[4], "Change light level      (Current: %d)",
+	    Sectors[obj->objnum].light);
+    sprintf(menustr[5], "Change type             (Current: %d)",
+	    Sectors[obj->objnum].special);
+    sprintf(menustr[6], "Change linedef tag      (Current: %d)",
+	    Sectors[obj->objnum].tag);
+    val = vDisplayMenu(x0, y0, menustr[7],
+		       menustr[0], YK_, 0,
+		       menustr[1], YK_, 0,
+		       menustr[2], YK_, 0,
+		       menustr[3], YK_, 0,
+		       menustr[4], YK_, 0,
+		       menustr[5], YK_, 0, menustr[6], YK_, 0, NULL);
+    for (n = 0; n < 8; n++)
+	FreeMemory(menustr[n]);
+    subwin_y0 = y0 + BOX_BORDER + (2 + val) * FONTH;
+    switch (val)
+    {
     case 1:
-      val = InputIntegerValue (x0 + 42, subwin_y0, -32768, 32767,
-	Sectors[obj->objnum].floorh);
-      if (val != IIV_CANCEL)
-      {
-	for (cur = obj; cur; cur = cur->next)
-	  Sectors[cur->objnum].floorh = val;
-	MadeChanges = 1;
-      }
-      break;
+	val = InputIntegerValue(x0 + 42, subwin_y0, -32768, 32767,
+				Sectors[obj->objnum].floorh);
+	if (val != IIV_CANCEL)
+	{
+	    for (cur = obj; cur; cur = cur->next)
+		Sectors[cur->objnum].floorh = val;
+	    MadeChanges = 1;
+	}
+	break;
 
     case 2:
-      val = InputIntegerValue (x0 + 42, subwin_y0, -32768, 32767,
-	Sectors[obj->objnum].ceilh);
-      if (val != IIV_CANCEL)
-      {
-	for (cur = obj; cur; cur = cur->next)
-	  Sectors[cur->objnum].ceilh = val;
-	MadeChanges = 1;
-      }
-      break;
+	val = InputIntegerValue(x0 + 42, subwin_y0, -32768, 32767,
+				Sectors[obj->objnum].ceilh);
+	if (val != IIV_CANCEL)
+	{
+	    for (cur = obj; cur; cur = cur->next)
+		Sectors[cur->objnum].ceilh = val;
+	    MadeChanges = 1;
+	}
+	break;
 
     case 3:
-      {
-	*texname = '\0';
-	strncat (texname, Sectors[obj->objnum].floort, WAD_FLAT_NAME);
-	char **flat_names =
-	  (char **) GetMemory (NumFTexture * sizeof *flat_names);
-	for (size_t n = 0; n < NumFTexture; n++)
-	  flat_names[n] = flat_list[n].name;
-	ChooseFloorTexture (x0 + 42, subwin_y0, "Choose a floor texture",
-	  NumFTexture, flat_names, texname);
-	FreeMemory (flat_names);
-	if (strlen (texname) > 0)
 	{
-	  for (cur = obj; cur; cur = cur->next)
-	    strncpy (Sectors[cur->objnum].floort, texname, WAD_FLAT_NAME);
-	  MadeChanges = 1;
+	    *texname = '\0';
+	    strncat(texname, Sectors[obj->objnum].floort, WAD_FLAT_NAME);
+	    char **flat_names =
+		(char **) GetMemory(NumFTexture * sizeof *flat_names);
+	    for (size_t n = 0; n < NumFTexture; n++)
+		flat_names[n] = flat_list[n].name;
+	    ChooseFloorTexture(x0 + 42, subwin_y0, "Choose a floor texture",
+			       NumFTexture, flat_names, texname);
+	    FreeMemory(flat_names);
+	    if (strlen(texname) > 0)
+	    {
+		for (cur = obj; cur; cur = cur->next)
+		    strncpy(Sectors[cur->objnum].floort, texname,
+			    WAD_FLAT_NAME);
+		MadeChanges = 1;
+	    }
+	    break;
 	}
-	break;
-      }
 
     case 4:
-      {
-      *texname = '\0';
-      strncat (texname, Sectors[obj->objnum].ceilt, WAD_FLAT_NAME);
-      char **flat_names =
-	(char **) GetMemory (NumFTexture * sizeof *flat_names);
-      for (size_t n = 0; n < NumFTexture; n++)
-	flat_names[n] = flat_list[n].name;
-      ChooseFloorTexture (x0 + 42, subwin_y0, "Choose a ceiling texture",
-	NumFTexture, flat_names, texname);
-      FreeMemory (flat_names);
-      if (strlen (texname) > 0)
-      {
-	for (cur = obj; cur; cur = cur->next)
-	  strncpy (Sectors[cur->objnum].ceilt, texname, WAD_FLAT_NAME);
-	MadeChanges = 1;
-      }
-      break;
-      }
+	{
+	    *texname = '\0';
+	    strncat(texname, Sectors[obj->objnum].ceilt, WAD_FLAT_NAME);
+	    char **flat_names =
+		(char **) GetMemory(NumFTexture * sizeof *flat_names);
+	    for (size_t n = 0; n < NumFTexture; n++)
+		flat_names[n] = flat_list[n].name;
+	    ChooseFloorTexture(x0 + 42, subwin_y0, "Choose a ceiling texture",
+			       NumFTexture, flat_names, texname);
+	    FreeMemory(flat_names);
+	    if (strlen(texname) > 0)
+	    {
+		for (cur = obj; cur; cur = cur->next)
+		    strncpy(Sectors[cur->objnum].ceilt, texname,
+			    WAD_FLAT_NAME);
+		MadeChanges = 1;
+	    }
+	    break;
+	}
 
     case 5:
-      val = InputIntegerValue (x0 + 42, subwin_y0, 0, 255,
-	Sectors[obj->objnum].light);
-      if (val != IIV_CANCEL)
-      {
-	for (cur = obj; cur; cur = cur->next)
-	  Sectors[cur->objnum].light = val;
-	MadeChanges = 1;
-      }
-      break;
+	val = InputIntegerValue(x0 + 42, subwin_y0, 0, 255,
+				Sectors[obj->objnum].light);
+	if (val != IIV_CANCEL)
+	{
+	    for (cur = obj; cur; cur = cur->next)
+		Sectors[cur->objnum].light = val;
+	    MadeChanges = 1;
+	}
+	break;
 
     case 6:
-      {
-	val = 0;
-	Menu_data_st menudata (stdef);
-	if (DisplayMenuList (x0 + 42, subwin_y0, "Select type", menudata, &val)
-	  < 0)
-	  break;
-	// KLUDGE last element of stdef means "enter value"
-	if (val == al_lcount (stdef) - 1)
 	{
-	  val = InputIntegerValue (x0 + 84,
-	    subwin_y0 + BOX_BORDER + (3 + val) * FONTH,
-	    -32768, 32767, 0);
-	  if (val == IIV_CANCEL)  // [Esc]
+	    val = 0;
+	    Menu_data_st menudata(stdef);
+	    if (DisplayMenuList
+		(x0 + 42, subwin_y0, "Select type", menudata, &val) < 0)
+		break;
+	    // KLUDGE last element of stdef means "enter value"
+	    if (val == al_lcount(stdef) - 1)
+	    {
+		val = InputIntegerValue(x0 + 84,
+					subwin_y0 + BOX_BORDER + (3 +
+								  val) *
+					FONTH, -32768, 32767, 0);
+		if (val == IIV_CANCEL)	// [Esc]
+		    break;
+	    }
+	    else
+	    {
+		if (al_lseek(stdef, val, SEEK_SET))
+		    fatal_error("%s SP1 (%s)\n",
+				msg_unexpected, al_astrerror(al_aerrno));
+		val = CUR_STDEF->number;
+	    }
+	    for (cur = obj; cur; cur = cur->next)
+		Sectors[cur->objnum].special = val;
+	    MadeChanges = 1;
 	    break;
 	}
-	else
-	{
-	  if (al_lseek (stdef, val, SEEK_SET))
-	    fatal_error ("%s SP1 (%s)\n",
-	      msg_unexpected, al_astrerror (al_aerrno));
-	  val = CUR_STDEF->number;
-	}
-	for (cur = obj; cur; cur = cur->next)
-	  Sectors[cur->objnum].special = val;
-	MadeChanges = 1;
-	break;
-      }
 
     case 7:
-      val = InputIntegerValue (x0 + 42, subwin_y0, -32768, 32767,
-	Sectors[obj->objnum].tag);
-      if (val != IIV_CANCEL)
-      {
-	for (cur = obj; cur; cur = cur->next)
-	  Sectors[cur->objnum].tag = val;
-	MadeChanges = 1;
-      }
-      break;
-  }
+	val = InputIntegerValue(x0 + 42, subwin_y0, -32768, 32767,
+				Sectors[obj->objnum].tag);
+	if (val != IIV_CANCEL)
+	{
+	    for (cur = obj; cur; cur = cur->next)
+		Sectors[cur->objnum].tag = val;
+	    MadeChanges = 1;
+	}
+	break;
+    }
 }
 
 /*
@@ -260,28 +258,28 @@
  *
  *   -AJA- 2001-05-27
  */
-void TransferSectorProperties (int src_sector, SelPtr sectors)
+void TransferSectorProperties(int src_sector, SelPtr sectors)
 {
-   SelPtr cur;
+    SelPtr cur;
 
-   for (cur=sectors; cur; cur=cur->next)
-   {
-     if (! is_obj(cur->objnum))
-         continue;
+    for (cur = sectors; cur; cur = cur->next)
+    {
+	if (!is_obj(cur->objnum))
+	    continue;
 
-      strncpy (Sectors[cur->objnum].floort, Sectors[src_sector].floort,
-            WAD_FLAT_NAME);
-      strncpy (Sectors[cur->objnum].ceilt, Sectors[src_sector].ceilt,
-            WAD_FLAT_NAME);
+	strncpy(Sectors[cur->objnum].floort, Sectors[src_sector].floort,
+		WAD_FLAT_NAME);
+	strncpy(Sectors[cur->objnum].ceilt, Sectors[src_sector].ceilt,
+		WAD_FLAT_NAME);
 
-      Sectors[cur->objnum].floorh  = Sectors[src_sector].floorh;
-      Sectors[cur->objnum].ceilh   = Sectors[src_sector].ceilh;
-      Sectors[cur->objnum].light   = Sectors[src_sector].light;
-      Sectors[cur->objnum].special = Sectors[src_sector].special;
-      Sectors[cur->objnum].tag     = Sectors[src_sector].tag;
+	Sectors[cur->objnum].floorh = Sectors[src_sector].floorh;
+	Sectors[cur->objnum].ceilh = Sectors[src_sector].ceilh;
+	Sectors[cur->objnum].light = Sectors[src_sector].light;
+	Sectors[cur->objnum].special = Sectors[src_sector].special;
+	Sectors[cur->objnum].tag = Sectors[src_sector].tag;
 
-      MadeChanges = 1;
-   }
+	MadeChanges = 1;
+    }
 }
 
 /*
@@ -289,32 +287,32 @@
  * 	Let the user select a sector type number and return it
  * 	Returns 0 if OK, <>0 if cancelled
  */
-int InputSectorType (int x0, int y0, int *number)
+int InputSectorType(int x0, int y0, int *number)
 {
-  int	val;
-  val = 0;
-  *number = 0;
-  Menu_data_st menudata (stdef);
-	if (DisplayMenuList (x0 , y0, "Select type", menudata, &val)
-	  < 0)
-	  return 1;
-  // KLUDGE last element of stdef means "enter value"
-  if (val == al_lcount (stdef) - 1)
-  	{
-	  val = InputIntegerValue (x0 + 84,
-	    y0 + BOX_BORDER + (3 + val) * FONTH,
-	    -32768, 32767, 0);
-	  if (val == IIV_CANCEL)  // [Esc]
+    int val;
+    val = 0;
+    *number = 0;
+    Menu_data_st menudata(stdef);
+    if (DisplayMenuList(x0, y0, "Select type", menudata, &val) < 0)
+	return 1;
+    // KLUDGE last element of stdef means "enter value"
+    if (val == al_lcount(stdef) - 1)
+    {
+	val = InputIntegerValue(x0 + 84,
+				y0 + BOX_BORDER + (3 + val) * FONTH,
+				-32768, 32767, 0);
+	if (val == IIV_CANCEL)	// [Esc]
 	    return 1;
-	}
-	else
-	{
-	  if (al_lseek (stdef, val, SEEK_SET))
-	    fatal_error ("%s SP1 (%s)\n",
-	      msg_unexpected, al_astrerror (al_aerrno));
-	  val = CUR_STDEF->number;
-	}
-  if (val < 0) return 1;  //unsuccessful
-  *number = val;
-  return 0;               //successful
+    }
+    else
+    {
+	if (al_lseek(stdef, val, SEEK_SET))
+	    fatal_error("%s SP1 (%s)\n",
+			msg_unexpected, al_astrerror(al_aerrno));
+	val = CUR_STDEF->number;
+    }
+    if (val < 0)
+	return 1;		//unsuccessful
+    *number = val;
+    return 0;			//successful
 }
--- a/src/s_slice.cc	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/s_slice.cc	Sat Sep 24 14:16:04 2011 +0300
@@ -39,8 +39,9 @@
 
 class Secref			// Reference to a sector
 {
-  public :
-    Secref () : linedef1 ('\0'), linedef2 ('\0') { }
+    public:Secref():linedef1('\0'), linedef2('\0')
+    {
+    }
     char linedef1;
     char linedef2;
 };
@@ -49,259 +50,260 @@
 /*
  *	sector_slice - cut a slice out of a sector
  */
-void sector_slice (obj_no_t linedef1, obj_no_t linedef2)
+void sector_slice(obj_no_t linedef1, obj_no_t linedef2)
 {
-  /* We have between 0 and 4 sidedefs. We need to make sure that
-     there are exactly 2 that face the same sector and that they
-     belong to different linedefs.
+    /* We have between 0 and 4 sidedefs. We need to make sure that
+       there are exactly 2 that face the same sector and that they
+       belong to different linedefs.
 
-     If a linedef has more than one sidedef that faces the same
-     sector, we can't decide which one faces the other linedef.
-     Well, we can but it's hard for a dummy like me.
+       If a linedef has more than one sidedef that faces the same
+       sector, we can't decide which one faces the other linedef.
+       Well, we can but it's hard for a dummy like me.
 
-     The problem is the same if the linedefs have two sectors in
-     common. Consider the following setup :
-		____________________________________
-	       |                                    |
-	       |              sector 0              |
-	       |      ________________________      |
-	       |     |                        |     |
-	       |     |        sector 1        |     |
-	       |     |      ____________      |     |
-	       |     |     |            |     |     |
-	       |     |     |  sector 0  |-L1  |-L2  |
-	       |     |     |____________|     |     |
-	       |     |                        |     |
-	       |     |                        |     |
-	       |     |________________________|     |
-	       |                                    |
-	       |                                    |
-	       |____________________________________|
+       The problem is the same if the linedefs have two sectors in
+       common. Consider the following setup :
+       ____________________________________
+       |                                    |
+       |              sector 0              |
+       |      ________________________      |
+       |     |                        |     |
+       |     |        sector 1        |     |
+       |     |      ____________      |     |
+       |     |     |            |     |     |
+       |     |     |  sector 0  |-L1  |-L2  |
+       |     |     |____________|     |     |
+       |     |                        |     |
+       |     |                        |     |
+       |     |________________________|     |
+       |                                    |
+       |                                    |
+       |____________________________________|
 
-     How do you decide to which vertex of L2 should the start
-     vertex of L1 be linked ? */
+       How do you decide to which vertex of L2 should the start
+       vertex of L1 be linked ? */
 
-  if (! is_linedef (linedef1))		// Paranoia
-  {
-    char buf[100];
-    y_snprintf (buf, sizeof buf,
-	"First argument is not a valid linedef number");
-    Notify (-1, -1, buf, 0);
-    return;
-  }
+    if (!is_linedef(linedef1))	// Paranoia
+    {
+	char buf[100];
+	y_snprintf(buf, sizeof buf,
+		   "First argument is not a valid linedef number");
+	Notify(-1, -1, buf, 0);
+	return;
+    }
 
-  if (! is_linedef (linedef2))		// Paranoia
-  {
-    char buf[100];
-    y_snprintf (buf, sizeof buf,
-	"Second argument is not a valid linedef number");
-    Notify (-1, -1, buf, 0);
-    return;
-  }
+    if (!is_linedef(linedef2))	// Paranoia
+    {
+	char buf[100];
+	y_snprintf(buf, sizeof buf,
+		   "Second argument is not a valid linedef number");
+	Notify(-1, -1, buf, 0);
+	return;
+    }
 
-  if (linedef1 == linedef2)
-  {
-    char buf[100];
-    y_snprintf (buf, sizeof buf, "Both arguments are the same linedef");
-    Notify (-1, -1, buf, 0);
-    return;
-  }
+    if (linedef1 == linedef2)
+    {
+	char buf[100];
+	y_snprintf(buf, sizeof buf, "Both arguments are the same linedef");
+	Notify(-1, -1, buf, 0);
+	return;
+    }
 
-  obj_no_t l1start = LineDefs[linedef1].start;
-  obj_no_t l1end   = LineDefs[linedef1].end;
-  obj_no_t l2start = LineDefs[linedef2].start;
-  obj_no_t l2end   = LineDefs[linedef2].end;
+    obj_no_t l1start = LineDefs[linedef1].start;
+    obj_no_t l1end = LineDefs[linedef1].end;
+    obj_no_t l2start = LineDefs[linedef2].start;
+    obj_no_t l2end = LineDefs[linedef2].end;
 
-  if (l1start == l2start && l1end == l2end
-    || l1start == l2end && l1end == l2start)
-  {
-    char buf[100];
-    y_snprintf (buf, sizeof buf, "Linedefs %d and %d are superimposed",
-        int (linedef1), int (linedef2));
-    Notify (-1, -1, buf, 0);
-    return;
-  }
+    if (l1start == l2start && l1end == l2end
+	|| l1start == l2end && l1end == l2start)
+    {
+	char buf[100];
+	y_snprintf(buf, sizeof buf, "Linedefs %d and %d are superimposed",
+		   int (linedef1), int (linedef2));
+	Notify(-1, -1, buf, 0);
+	return;
+    }
 
-  obj_no_t l1sdr = LineDefs[linedef1].sidedef1;
-  obj_no_t l1sdl = LineDefs[linedef1].sidedef2;
-  obj_no_t l2sdr = LineDefs[linedef2].sidedef1;
-  obj_no_t l2sdl = LineDefs[linedef2].sidedef2;
+    obj_no_t l1sdr = LineDefs[linedef1].sidedef1;
+    obj_no_t l1sdl = LineDefs[linedef1].sidedef2;
+    obj_no_t l2sdr = LineDefs[linedef2].sidedef1;
+    obj_no_t l2sdl = LineDefs[linedef2].sidedef2;
 
-  obj_no_t l1sr = is_sidedef (l1sdr) ? SideDefs[l1sdr].sector : OBJ_NO_NONE;
-  obj_no_t l1sl = is_sidedef (l1sdl) ? SideDefs[l1sdl].sector : OBJ_NO_NONE;
-  obj_no_t l2sr = is_sidedef (l2sdr) ? SideDefs[l2sdr].sector : OBJ_NO_NONE;
-  obj_no_t l2sl = is_sidedef (l2sdl) ? SideDefs[l2sdl].sector : OBJ_NO_NONE;
+    obj_no_t l1sr = is_sidedef(l1sdr) ? SideDefs[l1sdr].sector : OBJ_NO_NONE;
+    obj_no_t l1sl = is_sidedef(l1sdl) ? SideDefs[l1sdl].sector : OBJ_NO_NONE;
+    obj_no_t l2sr = is_sidedef(l2sdr) ? SideDefs[l2sdr].sector : OBJ_NO_NONE;
+    obj_no_t l2sl = is_sidedef(l2sdl) ? SideDefs[l2sdl].sector : OBJ_NO_NONE;
 
-  if (is_sector (l1sr) && is_sector (l1sl) && l1sr == l1sl)
-  {
-    char buf[100];
-    y_snprintf (buf, sizeof buf, "Linedef %d has both sides in the same sector",
-	int (linedef1));
-    Notify (-1, -1, buf, 0);
-    return;
-  }
+    if (is_sector(l1sr) && is_sector(l1sl) && l1sr == l1sl)
+    {
+	char buf[100];
+	y_snprintf(buf, sizeof buf,
+		   "Linedef %d has both sides in the same sector",
+		   int (linedef1));
+	Notify(-1, -1, buf, 0);
+	return;
+    }
 
-  if (is_sector (l2sr) && is_sector (l2sl) && l2sr == l2sl)
-  {
-    char buf[100];
-    y_snprintf (buf, sizeof buf, "Linedef %d has both sides in the same sector",
-	int (linedef2));
-    Notify (-1, -1, buf, 0);
-    return;
-  }
+    if (is_sector(l2sr) && is_sector(l2sl) && l2sr == l2sl)
+    {
+	char buf[100];
+	y_snprintf(buf, sizeof buf,
+		   "Linedef %d has both sides in the same sector",
+		   int (linedef2));
+	Notify(-1, -1, buf, 0);
+	return;
+    }
 
-  // Verify that the linedefs have exactly one sector in common
-  typedef std::map<obj_no_t, Secref> secref_list_t;
-  secref_list_t secref;
-  if (is_sector (l1sr))
-    secref[l1sr].linedef1 = 'r';
-  if (is_sector (l1sl))
-    secref[l1sl].linedef1 = 'l';
-  if (is_sector (l2sr))
-    secref[l2sr].linedef2 = 'r';
-  if (is_sector (l2sl))
-    secref[l2sl].linedef2 = 'l';
-  obj_no_t sector;
-  int count = 0;
-  for (secref_list_t::iterator i = secref.begin (); i != secref.end (); i++)
-  {
-    if (i->second.linedef1 != '\0' && i->second.linedef2 != '\0')
+    // Verify that the linedefs have exactly one sector in common
+    typedef std::map < obj_no_t, Secref > secref_list_t;
+    secref_list_t secref;
+    if (is_sector(l1sr))
+	secref[l1sr].linedef1 = 'r';
+    if (is_sector(l1sl))
+	secref[l1sl].linedef1 = 'l';
+    if (is_sector(l2sr))
+	secref[l2sr].linedef2 = 'r';
+    if (is_sector(l2sl))
+	secref[l2sl].linedef2 = 'l';
+    obj_no_t sector;
+    int count = 0;
+    for (secref_list_t::iterator i = secref.begin(); i != secref.end(); i++)
     {
-      sector = i->first;
-      count++;
+	if (i->second.linedef1 != '\0' && i->second.linedef2 != '\0')
+	{
+	    sector = i->first;
+	    count++;
+	}
     }
-  }
-  if (count < 1)
-  {
-    char buf[100];
-    y_snprintf (buf, sizeof buf,
-	"Linedefs %d and %d don't face the same sector",
-	int (linedef1), int (linedef2));
-    Notify (-1, -1, buf, 0);
-    return;
-  }
-  if (count > 1)
-  {
-    char buf[100];
-    y_snprintf (buf, sizeof buf,
-	"Linedefs %d and %d have more than one sector in common",
-	int (linedef1), int (linedef2));
-    Notify (-1, -1, buf, 0);
-    return;
-  }
+    if (count < 1)
+    {
+	char buf[100];
+	y_snprintf(buf, sizeof buf,
+		   "Linedefs %d and %d don't face the same sector",
+		   int (linedef1), int (linedef2));
+	Notify(-1, -1, buf, 0);
+	return;
+    }
+    if (count > 1)
+    {
+	char buf[100];
+	y_snprintf(buf, sizeof buf,
+		   "Linedefs %d and %d have more than one sector in common",
+		   int (linedef1), int (linedef2));
+	Notify(-1, -1, buf, 0);
+	return;
+    }
 
-  // Insert new sector between linedefs
-  obj_no_t la0, la1;		// Start and end of the first linedef (the
-				// one that goes from linedef1 to linedef2)
-  obj_no_t lb0, lb1;		// Start and end of the second linedef (the
-				// one that goes from linedef2 to linedef1)
-  char side = secref[sector].linedef1;
-  if (side == 'r')
-  {
-    la0 = l1end;
-    lb1 = l1start;
-  }
-  else if (side == 'l')
-  {
-    la0 = l1start;
-    lb1 = l1end;
-  }
-  else					// Can't happen
-  {
-    nf_bug ("sector %d: linedef1 = %02Xh", int (sector), side);
-    return;
-  }
+    // Insert new sector between linedefs
+    obj_no_t la0, la1;		// Start and end of the first linedef (the
+    // one that goes from linedef1 to linedef2)
+    obj_no_t lb0, lb1;		// Start and end of the second linedef (the
+    // one that goes from linedef2 to linedef1)
+    char side = secref[sector].linedef1;
+    if (side == 'r')
+    {
+	la0 = l1end;
+	lb1 = l1start;
+    }
+    else if (side == 'l')
+    {
+	la0 = l1start;
+	lb1 = l1end;
+    }
+    else			// Can't happen
+    {
+	nf_bug("sector %d: linedef1 = %02Xh", int (sector), side);
+	return;
+    }
 
-  side = secref[sector].linedef2;
-  if (side == 'r')
-  {
-    la1 = l2start;
-    lb0 = l2end;
-  }
-  else if (side == 'l')
-  {
-    la1 = l2end;
-    lb0 = l2start;
-  }
-  else					// Can't happen
-  {
-    nf_bug ("sector %d: linedef2 = %02Xh", int (sector), side);
-    return;
-  }
+    side = secref[sector].linedef2;
+    if (side == 'r')
+    {
+	la1 = l2start;
+	lb0 = l2end;
+    }
+    else if (side == 'l')
+    {
+	la1 = l2end;
+	lb0 = l2start;
+    }
+    else			// Can't happen
+    {
+	nf_bug("sector %d: linedef2 = %02Xh", int (sector), side);
+	return;
+    }
 
-  // Verify that there's no linedef already between linedef1 and linedef2
-  {
-    for (int n = 0; n < NumLineDefs; n++)
+    // Verify that there's no linedef already between linedef1 and linedef2
     {
-      if (n == linedef1 || n == linedef2)
-	continue;
-      if (LineDefs[n].start == la0 && LineDefs[n].end == la1
-       || LineDefs[n].start == la1 && LineDefs[n].end == la0
-       || LineDefs[n].start == lb0 && LineDefs[n].end == lb1
-       || LineDefs[n].start == lb1 && LineDefs[n].end == lb0)
-      {
-	char buf[100];
-	y_snprintf (buf, sizeof buf,
-	    "A linedef already exists between linedefs %d and %d (linedef %d)",
-	    int (linedef1), int (linedef2), int (n));
-	Notify (-1, -1, buf, 0);
-	return;
-      }
+	for (int n = 0; n < NumLineDefs; n++)
+	{
+	    if (n == linedef1 || n == linedef2)
+		continue;
+	    if (LineDefs[n].start == la0 && LineDefs[n].end == la1
+		|| LineDefs[n].start == la1 && LineDefs[n].end == la0
+		|| LineDefs[n].start == lb0 && LineDefs[n].end == lb1
+		|| LineDefs[n].start == lb1 && LineDefs[n].end == lb0)
+	    {
+		char buf[100];
+		y_snprintf(buf, sizeof buf,
+			   "A linedef already exists between linedefs %d and %d (linedef %d)",
+			   int (linedef1), int (linedef2), int (n));
+		Notify(-1, -1, buf, 0);
+		return;
+	    }
+	}
     }
-  }
-  
-  // Create new sector
-  InsertObject (OBJ_SECTORS, sector, 0, 0);
+
+    // Create new sector
+    InsertObject(OBJ_SECTORS, sector, 0, 0);
 
-  // Create new linedef from linedef1 to linedef2
-  if (la0 != la1)
-  {
-    InsertObject (OBJ_LINEDEFS, -1, 0, 0);
-    LineDefs[NumLineDefs - 1].start = la0;
-    LineDefs[NumLineDefs - 1].end   = la1;
-    LineDefs[NumLineDefs - 1].flags = 4;
-    InsertObject (OBJ_SIDEDEFS, -1, 0, 0);		// Right sidedef
-    SideDefs[NumSideDefs - 1].sector = NumSectors - 1;	// Redundant
-    strncpy (SideDefs[NumSideDefs - 1].tex3, "-", 8);
-    LineDefs[NumLineDefs - 1].sidedef1 = NumSideDefs - 1;
-    InsertObject (OBJ_SIDEDEFS, -1, 0, 0);		// Left sidedef
-    SideDefs[NumSideDefs - 1].sector = sector;
-    strncpy (SideDefs[NumSideDefs - 1].tex3, "-", 8);
-    LineDefs[NumLineDefs - 1].sidedef2 = NumSideDefs - 1;
-  }
+    // Create new linedef from linedef1 to linedef2
+    if (la0 != la1)
+    {
+	InsertObject(OBJ_LINEDEFS, -1, 0, 0);
+	LineDefs[NumLineDefs - 1].start = la0;
+	LineDefs[NumLineDefs - 1].end = la1;
+	LineDefs[NumLineDefs - 1].flags = 4;
+	InsertObject(OBJ_SIDEDEFS, -1, 0, 0);	// Right sidedef
+	SideDefs[NumSideDefs - 1].sector = NumSectors - 1;	// Redundant
+	strncpy(SideDefs[NumSideDefs - 1].tex3, "-", 8);
+	LineDefs[NumLineDefs - 1].sidedef1 = NumSideDefs - 1;
+	InsertObject(OBJ_SIDEDEFS, -1, 0, 0);	// Left sidedef
+	SideDefs[NumSideDefs - 1].sector = sector;
+	strncpy(SideDefs[NumSideDefs - 1].tex3, "-", 8);
+	LineDefs[NumLineDefs - 1].sidedef2 = NumSideDefs - 1;
+    }
 
-  // Create new linedef from linedef2 to linedef1
-  if (lb0 != lb1)
-  {
-    InsertObject (OBJ_LINEDEFS, -1, 0, 0);
-    LineDefs[NumLineDefs - 1].start = lb0;
-    LineDefs[NumLineDefs - 1].end   = lb1;
-    LineDefs[NumLineDefs - 1].flags = 4;
-    InsertObject (OBJ_SIDEDEFS, -1, 0, 0);		// Right sidedef
-    SideDefs[NumSideDefs - 1].sector = NumSectors - 1;	// Redundant
-    strncpy (SideDefs[NumSideDefs - 1].tex3, "-", 8);
-    LineDefs[NumLineDefs - 1].sidedef1 = NumSideDefs - 1;
-    InsertObject (OBJ_SIDEDEFS, -1, 0, 0);		// Left sidedef
-    SideDefs[NumSideDefs - 1].sector = sector;
-    strncpy (SideDefs[NumSideDefs - 1].tex3, "-", 8);
-    LineDefs[NumLineDefs - 1].sidedef2 = NumSideDefs - 1;
-  }
+    // Create new linedef from linedef2 to linedef1
+    if (lb0 != lb1)
+    {
+	InsertObject(OBJ_LINEDEFS, -1, 0, 0);
+	LineDefs[NumLineDefs - 1].start = lb0;
+	LineDefs[NumLineDefs - 1].end = lb1;
+	LineDefs[NumLineDefs - 1].flags = 4;
+	InsertObject(OBJ_SIDEDEFS, -1, 0, 0);	// Right sidedef
+	SideDefs[NumSideDefs - 1].sector = NumSectors - 1;	// Redundant
+	strncpy(SideDefs[NumSideDefs - 1].tex3, "-", 8);
+	LineDefs[NumLineDefs - 1].sidedef1 = NumSideDefs - 1;
+	InsertObject(OBJ_SIDEDEFS, -1, 0, 0);	// Left sidedef
+	SideDefs[NumSideDefs - 1].sector = sector;
+	strncpy(SideDefs[NumSideDefs - 1].tex3, "-", 8);
+	LineDefs[NumLineDefs - 1].sidedef2 = NumSideDefs - 1;
+    }
 
-  // Adjust sector references for linedef1
-  side = secref[sector].linedef1;
-  if (side == 'r')
-    SideDefs[LineDefs[linedef1].sidedef1].sector = NumSectors - 1;
-  else if (side == 'l')
-    SideDefs[LineDefs[linedef1].sidedef2].sector = NumSectors - 1;
+    // Adjust sector references for linedef1
+    side = secref[sector].linedef1;
+    if (side == 'r')
+	SideDefs[LineDefs[linedef1].sidedef1].sector = NumSectors - 1;
+    else if (side == 'l')
+	SideDefs[LineDefs[linedef1].sidedef2].sector = NumSectors - 1;
 
-  // Adjust sector references for linedef2
-  side = secref[sector].linedef2;
-  if (side == 'r')
-    SideDefs[LineDefs[linedef2].sidedef1].sector = NumSectors - 1;
-  else if (side == 'l')
-    SideDefs[LineDefs[linedef2].sidedef2].sector = NumSectors - 1;
+    // Adjust sector references for linedef2
+    side = secref[sector].linedef2;
+    if (side == 'r')
+	SideDefs[LineDefs[linedef2].sidedef1].sector = NumSectors - 1;
+    else if (side == 'l')
+	SideDefs[LineDefs[linedef2].sidedef2].sector = NumSectors - 1;
 
-  MadeChanges = 1;
-  MadeMapChanges = 1;
+    MadeChanges = 1;
+    MadeMapChanges = 1;
 }
-
--- a/src/s_slice.h	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/s_slice.h	Sat Sep 24 14:16:04 2011 +0300
@@ -4,11 +4,11 @@
  */
 
 
-#ifndef YH_S_SLICE  /* DO NOT INSERT ANYTHING BEFORE THIS LINE */
+#ifndef YH_S_SLICE		/* DO NOT INSERT ANYTHING BEFORE THIS LINE */
 #define YH_S_SLICE
 
 
-void sector_slice (obj_no_t linedef1, obj_no_t linedef2);
+void sector_slice(obj_no_t linedef1, obj_no_t linedef2);
 
 
-#endif  /* DO NOT ADD ANYTHING AFTER THIS LINE */
+#endif /* DO NOT ADD ANYTHING AFTER THIS LINE */
--- a/src/s_split.cc	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/s_split.cc	Sat Sep 24 14:16:04 2011 +0300
@@ -43,141 +43,144 @@
    split a sector in two, adding a new linedef between the two vertices
 */
 
-void SplitSector (int vertex1, int vertex2) /* SWAP! */
+void SplitSector(int vertex1, int vertex2)	/* SWAP! */
 {
-SelPtr llist;
-int    curv, s, l, sd;
-char   msg1[80], msg2[80];
+    SelPtr llist;
+    int curv, s, l, sd;
+    char msg1[80], msg2[80];
 
 /* AYM 1998-08-09 : FIXME : I'm afraid this test is not relevant
    if the sector contains subsectors. I should ask Jim (Flynn),
    he did something about that in DETH. */
 /* Check if there is a sector between the two vertices (in the middle) */
-Objid o;
-GetCurObject (o, OBJ_SECTORS,
-	      (Vertices[vertex1].x + Vertices[vertex2].x) / 2,
-	      (Vertices[vertex1].y + Vertices[vertex2].y) / 2);
-s = o.num;
-if (s < 0)
-   {
-   Beep ();
-   sprintf (msg1, "There is no sector between vertex #%d and vertex #%d",
-     vertex1, vertex2);
-   Notify (-1, -1, msg1, NULL);
-   return;
-   }
+    Objid o;
+    GetCurObject(o, OBJ_SECTORS,
+		 (Vertices[vertex1].x + Vertices[vertex2].x) / 2,
+		 (Vertices[vertex1].y + Vertices[vertex2].y) / 2);
+    s = o.num;
+    if (s < 0)
+    {
+	Beep();
+	sprintf(msg1, "There is no sector between vertex #%d and vertex #%d",
+		vertex1, vertex2);
+	Notify(-1, -1, msg1, NULL);
+	return;
+    }
 
 /* Check if there is a closed path from <vertex1> to <vertex2>,
    along the edge of sector <s>. To make it faster, I scan only
    the set of linedefs that face sector <s>. */
-obj_no_t *ld_numbers;
-int nlinedefs = linedefs_of_sector (s, ld_numbers);
-if (nlinedefs < 1)  // Can't happen
-   {
-   nf_bug ("SplitSector: no linedef for sector %d\n", s);
-   return;
-   }
-llist = NULL;
-curv = vertex1;
-while (curv != vertex2)
-   {
-   printf ("%d\n", curv);
-   int n;
-   for (n = 0; n < nlinedefs; n++)
-      {
-      if (IsSelected (llist, ld_numbers[n]))
-	 continue;  // Already been there
-      const LDPtr ld = LineDefs + ld_numbers[n];
-      if (ld->start == curv
-	  && is_sidedef (ld->sidedef1) && SideDefs[ld->sidedef1].sector == s)
-         {
-	 curv = ld->end;
-	 SelectObject (&llist, ld_numbers[n]);
-	 break;
-         }
-      if (ld->end == curv
-	  && is_sidedef (ld->sidedef2) && SideDefs[ld->sidedef2].sector == s)
-	 {
-	 curv = ld->start;
-	 SelectObject (&llist, ld_numbers[n]);
-	 break;
-         }
-      }
-   if (n >= nlinedefs)
-      {
-      Beep ();
-      sprintf (msg1, "Cannot find a closed path from vertex #%d to vertex #%d",
-        vertex1, vertex2);
-      if (curv == vertex1)
-	 sprintf (msg2, "There is no sidedef starting from vertex #%d"
-	   " on sector #%d", vertex1, s);
-      else
-	 sprintf (msg2, "Check if sector #%d is closed"
-	   " (cannot go past vertex #%d)", s, curv);
-      Notify (-1, -1, msg1, msg2);
-      ForgetSelection (&llist);
-      delete[] ld_numbers;
-      return;
-      }
-   if (curv == vertex1)
-      {
-      Beep ();
-      sprintf (msg1, "Vertex #%d is not on the same sector (#%d)"
-        " as vertex #%d", vertex2, s, vertex1);
-      Notify (-1, -1, msg1, NULL);
-      ForgetSelection (&llist);
-      delete[] ld_numbers;
-      return;
-      }
-   }
-delete[] ld_numbers;
+    obj_no_t *ld_numbers;
+    int nlinedefs = linedefs_of_sector(s, ld_numbers);
+    if (nlinedefs < 1)		// Can't happen
+    {
+	nf_bug("SplitSector: no linedef for sector %d\n", s);
+	return;
+    }
+    llist = NULL;
+    curv = vertex1;
+    while (curv != vertex2)
+    {
+	printf("%d\n", curv);
+	int n;
+	for (n = 0; n < nlinedefs; n++)
+	{
+	    if (IsSelected(llist, ld_numbers[n]))
+		continue;	// Already been there
+	    const LDPtr ld = LineDefs + ld_numbers[n];
+	    if (ld->start == curv
+		&& is_sidedef(ld->sidedef1)
+		&& SideDefs[ld->sidedef1].sector == s)
+	    {
+		curv = ld->end;
+		SelectObject(&llist, ld_numbers[n]);
+		break;
+	    }
+	    if (ld->end == curv
+		&& is_sidedef(ld->sidedef2)
+		&& SideDefs[ld->sidedef2].sector == s)
+	    {
+		curv = ld->start;
+		SelectObject(&llist, ld_numbers[n]);
+		break;
+	    }
+	}
+	if (n >= nlinedefs)
+	{
+	    Beep();
+	    sprintf(msg1,
+		    "Cannot find a closed path from vertex #%d to vertex #%d",
+		    vertex1, vertex2);
+	    if (curv == vertex1)
+		sprintf(msg2, "There is no sidedef starting from vertex #%d"
+			" on sector #%d", vertex1, s);
+	    else
+		sprintf(msg2, "Check if sector #%d is closed"
+			" (cannot go past vertex #%d)", s, curv);
+	    Notify(-1, -1, msg1, msg2);
+	    ForgetSelection(&llist);
+	    delete[]ld_numbers;
+	    return;
+	}
+	if (curv == vertex1)
+	{
+	    Beep();
+	    sprintf(msg1, "Vertex #%d is not on the same sector (#%d)"
+		    " as vertex #%d", vertex2, s, vertex1);
+	    Notify(-1, -1, msg1, NULL);
+	    ForgetSelection(&llist);
+	    delete[]ld_numbers;
+	    return;
+	}
+    }
+    delete[]ld_numbers;
 /* now, the list of linedefs for the new sector is in llist */
 
 /* add the new sector, linedef and sidedefs */
-InsertObject (OBJ_SECTORS, s, 0, 0);
-InsertObject (OBJ_LINEDEFS, -1, 0, 0);
-LineDefs[NumLineDefs - 1].start = vertex1;
-LineDefs[NumLineDefs - 1].end = vertex2;
-LineDefs[NumLineDefs - 1].flags = 4;
-InsertObject (OBJ_SIDEDEFS, -1, 0, 0);
-SideDefs[NumSideDefs - 1].sector = s;
-strncpy (SideDefs[NumSideDefs - 1].tex3, "-", WAD_TEX_NAME);
-InsertObject (OBJ_SIDEDEFS, -1, 0, 0);
-strncpy (SideDefs[NumSideDefs - 1].tex3, "-", WAD_TEX_NAME);
-LineDefs[NumLineDefs - 1].sidedef1 = NumSideDefs - 2;
-LineDefs[NumLineDefs - 1].sidedef2 = NumSideDefs - 1;
+    InsertObject(OBJ_SECTORS, s, 0, 0);
+    InsertObject(OBJ_LINEDEFS, -1, 0, 0);
+    LineDefs[NumLineDefs - 1].start = vertex1;
+    LineDefs[NumLineDefs - 1].end = vertex2;
+    LineDefs[NumLineDefs - 1].flags = 4;
+    InsertObject(OBJ_SIDEDEFS, -1, 0, 0);
+    SideDefs[NumSideDefs - 1].sector = s;
+    strncpy(SideDefs[NumSideDefs - 1].tex3, "-", WAD_TEX_NAME);
+    InsertObject(OBJ_SIDEDEFS, -1, 0, 0);
+    strncpy(SideDefs[NumSideDefs - 1].tex3, "-", WAD_TEX_NAME);
+    LineDefs[NumLineDefs - 1].sidedef1 = NumSideDefs - 2;
+    LineDefs[NumLineDefs - 1].sidedef2 = NumSideDefs - 1;
 
 /* bind all linedefs in llist to the new sector */
-while (llist)
-{
-   sd = LineDefs[llist->objnum].sidedef1;
-   if (sd < 0 || SideDefs[sd].sector != s)
-      sd = LineDefs[llist->objnum].sidedef2;
-   SideDefs[sd].sector = NumSectors - 1;
-   UnSelectObject (&llist, llist->objnum);
-}
+    while (llist)
+    {
+	sd = LineDefs[llist->objnum].sidedef1;
+	if (sd < 0 || SideDefs[sd].sector != s)
+	    sd = LineDefs[llist->objnum].sidedef2;
+	SideDefs[sd].sector = NumSectors - 1;
+	UnSelectObject(&llist, llist->objnum);
+    }
 
 /* second check... useful for sectors within sectors */
-for (l = 0; l < NumLineDefs; l++)
-{
-   sd = LineDefs[l].sidedef1;
-   if (sd >= 0 && SideDefs[sd].sector == s)
-   {
-      curv = GetOppositeSector (l, 1);
-      if (curv == NumSectors - 1)
-	 SideDefs[sd].sector = NumSectors - 1;
-   }
-   sd = LineDefs[l].sidedef2;
-   if (sd >= 0 && SideDefs[sd].sector == s)
-   {
-      curv = GetOppositeSector (l, 0);
-      if (curv == NumSectors - 1)
-	 SideDefs[sd].sector = NumSectors - 1;
-   }
-}
+    for (l = 0; l < NumLineDefs; l++)
+    {
+	sd = LineDefs[l].sidedef1;
+	if (sd >= 0 && SideDefs[sd].sector == s)
+	{
+	    curv = GetOppositeSector(l, 1);
+	    if (curv == NumSectors - 1)
+		SideDefs[sd].sector = NumSectors - 1;
+	}
+	sd = LineDefs[l].sidedef2;
+	if (sd >= 0 && SideDefs[sd].sector == s)
+	{
+	    curv = GetOppositeSector(l, 0);
+	    if (curv == NumSectors - 1)
+		SideDefs[sd].sector = NumSectors - 1;
+	}
+    }
 
-MadeChanges = 1;
-MadeMapChanges = 1;
+    MadeChanges = 1;
+    MadeMapChanges = 1;
 }
 
 
@@ -186,42 +189,41 @@
    split two linedefs, then split the sector and add a new linedef between the new vertices
 */
 
-void SplitLineDefsAndSector (int linedef1, int linedef2) /* SWAP! */
+void SplitLineDefsAndSector(int linedef1, int linedef2)	/* SWAP! */
 {
-SelPtr llist;
-int    s1, s2, s3, s4;
-char   msg[80];
+    SelPtr llist;
+    int s1, s2, s3, s4;
+    char msg[80];
 
 /* check if the two linedefs are adjacent to the same sector */
-s1 = LineDefs[linedef1].sidedef1;
-s2 = LineDefs[linedef1].sidedef2;
-s3 = LineDefs[linedef2].sidedef1;
-s4 = LineDefs[linedef2].sidedef2;
-if (s1 >= 0)
-   s1 = SideDefs[s1].sector;
-if (s2 >= 0)
-   s2 = SideDefs[s2].sector;
-if (s3 >= 0)
-   s3 = SideDefs[s3].sector;
-if (s4 >= 0)
-   s4 = SideDefs[s4].sector;
-if ((s1 < 0 || (s1 != s3 && s1 != s4)) && (s2 < 0 || (s2 != s3 && s2 != s4)))
-{
-   Beep ();
-   sprintf (msg, "Linedefs #%d and #%d are not adjacent to the same sector",
-     linedef1, linedef2);
-   Notify (-1, -1, msg, NULL);
-   return;
+    s1 = LineDefs[linedef1].sidedef1;
+    s2 = LineDefs[linedef1].sidedef2;
+    s3 = LineDefs[linedef2].sidedef1;
+    s4 = LineDefs[linedef2].sidedef2;
+    if (s1 >= 0)
+	s1 = SideDefs[s1].sector;
+    if (s2 >= 0)
+	s2 = SideDefs[s2].sector;
+    if (s3 >= 0)
+	s3 = SideDefs[s3].sector;
+    if (s4 >= 0)
+	s4 = SideDefs[s4].sector;
+    if ((s1 < 0 || (s1 != s3 && s1 != s4))
+	&& (s2 < 0 || (s2 != s3 && s2 != s4)))
+    {
+	Beep();
+	sprintf(msg,
+		"Linedefs #%d and #%d are not adjacent to the same sector",
+		linedef1, linedef2);
+	Notify(-1, -1, msg, NULL);
+	return;
+    }
+/* split the two linedefs and create two new vertices */
+    llist = NULL;
+    SelectObject(&llist, linedef1);
+    SelectObject(&llist, linedef2);
+    SplitLineDefs(llist);
+    ForgetSelection(&llist);
+/* split the sector and create a linedef between the two vertices */
+    SplitSector(NumVertices - 1, NumVertices - 2);
 }
-/* split the two linedefs and create two new vertices */
-llist = NULL;
-SelectObject (&llist, linedef1);
-SelectObject (&llist, linedef2);
-SplitLineDefs (llist);
-ForgetSelection (&llist);
-/* split the sector and create a linedef between the two vertices */
-SplitSector (NumVertices - 1, NumVertices - 2);
-}
-
-
-
--- a/src/s_swapf.cc	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/s_swapf.cc	Sat Sep 24 14:16:04 2011 +0300
@@ -33,17 +33,16 @@
 #include "selectn.h"
 
 
-void swap_flats (SelPtr list)
+void swap_flats(SelPtr list)
 {
-  for (SelPtr cur = list; cur != NULL; cur = cur->next)
-  {
-    wad_flat_name_t tmp;
-    struct Sector *s = Sectors + cur->objnum;
+    for (SelPtr cur = list; cur != NULL; cur = cur->next)
+    {
+	wad_flat_name_t tmp;
+	struct Sector *s = Sectors + cur->objnum;
 
-    memcpy (tmp,       s->floort, sizeof tmp);
-    memcpy (s->floort, s->ceilt,  sizeof s->floort);
-    memcpy (s->ceilt,  tmp,       sizeof s->ceilt);
-    MadeChanges = 1;
-  }
+	memcpy(tmp, s->floort, sizeof tmp);
+	memcpy(s->floort, s->ceilt, sizeof s->floort);
+	memcpy(s->ceilt, tmp, sizeof s->ceilt);
+	MadeChanges = 1;
+    }
 }
-
--- a/src/s_swapf.h	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/s_swapf.h	Sat Sep 24 14:16:04 2011 +0300
@@ -5,5 +5,4 @@
  */
 
 
-void swap_flats (SelPtr list);
-
+void swap_flats(SelPtr list);
--- a/src/s_vertices.cc	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/s_vertices.cc	Sat Sep 24 14:16:04 2011 +0300
@@ -41,12 +41,12 @@
  *	Return a bit vector of all vertices used by a sector.
  *	It's up to the caller to delete the bit vector after use.
  */
-bitvec_c *bv_vertices_of_sector (obj_no_t s)
+bitvec_c *bv_vertices_of_sector(obj_no_t s)
 {
-  bitvec_c *linedefs = linedefs_of_sector (s);
-  bitvec_c *vertices = bv_vertices_of_linedefs (linedefs);
-  delete linedefs;
-  return vertices;
+    bitvec_c *linedefs = linedefs_of_sector(s);
+    bitvec_c *vertices = bv_vertices_of_linedefs(linedefs);
+    delete linedefs;
+    return vertices;
 }
 
 
@@ -55,15 +55,15 @@
  *	Return a bit vector of all vertices used by the sectors.
  *	It's up to the caller to delete the bit vector after use.
  */
-bitvec_c *bv_vertices_of_sectors (SelPtr list)
+bitvec_c *bv_vertices_of_sectors(SelPtr list)
 {
-  bitvec_c *linedefs;  // Linedefs used by the sectors
-  bitvec_c *vertices;  // Vertices used by the linedefs
+    bitvec_c *linedefs;		// Linedefs used by the sectors
+    bitvec_c *vertices;		// Vertices used by the linedefs
 
-  linedefs = linedefs_of_sectors (list);
-  vertices = bv_vertices_of_linedefs (linedefs);
-  delete linedefs;
-  return vertices;
+    linedefs = linedefs_of_sectors(list);
+    vertices = bv_vertices_of_linedefs(linedefs);
+    delete linedefs;
+    return vertices;
 }
 
 
@@ -72,20 +72,18 @@
  *	Return a list of all vertices used by the sectors.
  *	It's up to the caller to delete the list after use.
  */
-SelPtr list_vertices_of_sectors (SelPtr list)
+SelPtr list_vertices_of_sectors(SelPtr list)
 {
-  bitvec_c *vertices_bitvec;
-  SelPtr vertices_list = 0;
-  size_t n;
+    bitvec_c *vertices_bitvec;
+    SelPtr vertices_list = 0;
+    size_t n;
 
-  vertices_bitvec = bv_vertices_of_sectors (list);
-  for (n = 0; n < vertices_bitvec->nelements (); n++)
-  {
-    if (vertices_bitvec->get (n))
-      SelectObject (&vertices_list, n);
-  }
-  delete vertices_bitvec;
-  return vertices_list;
+    vertices_bitvec = bv_vertices_of_sectors(list);
+    for (n = 0; n < vertices_bitvec->nelements(); n++)
+    {
+	if (vertices_bitvec->get(n))
+	    SelectObject(&vertices_list, n);
+    }
+    delete vertices_bitvec;
+    return vertices_list;
 }
-
-
--- a/src/s_vertices.h	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/s_vertices.h	Sat Sep 24 14:16:04 2011 +0300
@@ -8,7 +8,6 @@
 #include "selectn.h"
 
 
-bitvec_c *bv_vertices_of_sector (obj_no_t s);
-bitvec_c *bv_vertices_of_sectors (SelPtr list);
-SelPtr list_vertices_of_sectors (SelPtr list);
-
+bitvec_c *bv_vertices_of_sector(obj_no_t s);
+bitvec_c *bv_vertices_of_sectors(SelPtr list);
+SelPtr list_vertices_of_sectors(SelPtr list);
--- a/src/sanity.cc	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/sanity.cc	Sat Sep 24 14:16:04 2011 +0300
@@ -48,7 +48,7 @@
 	(int) sizeof (type));						\
   }									\
   while (0)
-   
+
 #define assert_wrap(type,high,low)					\
   do									\
   {									\
@@ -59,25 +59,25 @@
   }									\
   while (0)
 
-void check_types ()
+void check_types()
 {
-  assert_size (u8,  1);
-  assert_size (i8,  1);
-  assert_size (u16, 2);
-  assert_size (i16, 2);
-  assert_size (u32, 4);
-  assert_size (i32, 4);
-  assert_size (struct LineDef, 14);
-  assert_size (struct Sector,  26);
-  assert_size (struct SideDef, 30);
-  assert_size (struct Thing,   10);
-  assert_size (struct Vertex,   4);
-  assert_wrap (u8,          255,           0);
-  assert_wrap (i8,          127,        -128);
-  assert_wrap (u16,       65535,           0);
-  assert_wrap (i16,       32767,      -32768);
-  assert_wrap (u32, 4294967295u,           0);
-  assert_wrap (i32,  2147483647, -2147483648);
+    assert_size(u8, 1);
+    assert_size(i8, 1);
+    assert_size(u16, 2);
+    assert_size(i16, 2);
+    assert_size(u32, 4);
+    assert_size(i32, 4);
+    assert_size(struct LineDef, 14);
+    assert_size(struct Sector, 26);
+    assert_size(struct SideDef, 30);
+    assert_size(struct Thing, 10);
+    assert_size(struct Vertex, 4);
+    assert_wrap(u8, 255, 0);
+    assert_wrap(i8, 127, -128);
+    assert_wrap(u16, 65535, 0);
+    assert_wrap(i16, 32767, -32768);
+    assert_wrap(u32, 4294967295u, 0);
+    assert_wrap(i32, 2147483647, -2147483648);
 }
 
 
@@ -87,31 +87,27 @@
  *	If this test fails on your platform, send me a postcard
  *	from your galaxy.
  */
-void check_charset ()
+void check_charset()
 {
-  /* Always false, unless your platform uses a
-     character set even worse than EBCDIC (yet
-     unseen). */
-  if (   '0' + 1 != '1'
-      || '1' + 1 != '2'
-      || '2' + 1 != '3'
-      || '3' + 1 != '4'
-      || '4' + 1 != '5'
-      || '5' + 1 != '6'
-      || '6' + 1 != '7'
-      || '7' + 1 != '8'
-      || '8' + 1 != '9'
-      || 'a' + 1 != 'b'
-      || 'b' + 1 != 'c'
-      || 'c' + 1 != 'd'
-      || 'd' + 1 != 'e'
-      || 'e' + 1 != 'f'
-      || 'A' + 1 != 'B'
-      || 'B' + 1 != 'C'
-      || 'C' + 1 != 'D'
-      || 'D' + 1 != 'E'
-      || 'E' + 1 != 'F')
-    fatal_error ("This platform uses a terminally broken character set");
+    /* Always false, unless your platform uses a
+       character set even worse than EBCDIC (yet
+       unseen). */
+    if ('0' + 1 != '1'
+	|| '1' + 1 != '2'
+	|| '2' + 1 != '3'
+	|| '3' + 1 != '4'
+	|| '4' + 1 != '5'
+	|| '5' + 1 != '6'
+	|| '6' + 1 != '7'
+	|| '7' + 1 != '8'
+	|| '8' + 1 != '9'
+	|| 'a' + 1 != 'b'
+	|| 'b' + 1 != 'c'
+	|| 'c' + 1 != 'd'
+	|| 'd' + 1 != 'e'
+	|| 'e' + 1 != 'f'
+	|| 'A' + 1 != 'B'
+	|| 'B' + 1 != 'C'
+	|| 'C' + 1 != 'D' || 'D' + 1 != 'E' || 'E' + 1 != 'F')
+	fatal_error("This platform uses a terminally broken character set");
 }
-
-
--- a/src/sanity.h	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/sanity.h	Sat Sep 24 14:16:04 2011 +0300
@@ -4,7 +4,5 @@
  */
 
 
-void check_types ();
-void check_charset ();
-
-
+void check_types();
+void check_charset();
--- a/src/scrnshot.cc	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/scrnshot.cc	Sat Sep 24 14:16:04 2011 +0300
@@ -38,79 +38,77 @@
 
 
 #ifdef Y_DOS
-static int ShotGetPixel (int x, int y);
+static int ShotGetPixel(int x, int y);
 #endif
 
 
-void ScreenShot (void)
+void ScreenShot(void)
 #if defined Y_UNIX
 {
-  return;  // FIXME
+    return;			// FIXME
 }
 #elif defined Y_DOS
 {
-  int n;
-  int r;
-  int ShotWidth, ShotHeight;
+    int n;
+    int r;
+    int ShotWidth, ShotHeight;
 
-  ShotWidth = ScrMaxX+1;
-  ShotHeight = ScrMaxY+1-17-12;
+    ShotWidth = ScrMaxX + 1;
+    ShotHeight = ScrMaxY + 1 - 17 - 12;
 
-  LogMessage ("Writing screen shot to file yadex.gif\n");
-  r = GIF_Create ("yadex.gif", ShotWidth, ShotHeight, 16, 3);
-  if (r != GIF_OK)
-    LogMessage ("GIF_Create error %d\n", r);
-  GIF_SetColor ( 0, 0, 0, 0);  // BLACK
-  GIF_SetColor ( 1, 0, 0, 4);  // BLUE
-  GIF_SetColor ( 2, 0, 4, 0);  // GREEN
-  GIF_SetColor ( 3, 0, 4, 4);  // CYAN
-  GIF_SetColor ( 4, 4, 0, 0);  // RED
-  GIF_SetColor ( 5, 4, 0, 4);  // MAGENTA
-  GIF_SetColor ( 6, 4, 3, 0);  // BROWN
-  GIF_SetColor ( 7, 4, 4, 4);  // LIGHTGREY
-  GIF_SetColor ( 8, 2, 2, 2);  // DARKGREY
-  GIF_SetColor ( 9, 0, 0, 7);  // LIGHTBLUE
-  GIF_SetColor (10, 0, 7, 0);  // LIGHTGREEN
-  GIF_SetColor (11, 0, 7, 7);  // LIGHTCYAN
-  GIF_SetColor (12, 7, 0, 0);  // LIGHTRED
-  GIF_SetColor (13, 7, 0, 7);  // LIGHTMAGENTA
-  GIF_SetColor (14, 7, 7, 0);  // YELLOW
-  GIF_SetColor (15, 7, 7, 7);  // WHITE
-  r = GIF_CompressImage (0, 17, ShotWidth, ShotHeight, ShotGetPixel);
-  if (r != GIF_OK)
-    LogMessage ("GIF_CompressImage error %d\n", r);
-  r = GIF_Close ();
-  LogMessage ("GIF_Close returned %d\n", r);
+    LogMessage("Writing screen shot to file yadex.gif\n");
+    r = GIF_Create("yadex.gif", ShotWidth, ShotHeight, 16, 3);
+    if (r != GIF_OK)
+	LogMessage("GIF_Create error %d\n", r);
+    GIF_SetColor(0, 0, 0, 0);	// BLACK
+    GIF_SetColor(1, 0, 0, 4);	// BLUE
+    GIF_SetColor(2, 0, 4, 0);	// GREEN
+    GIF_SetColor(3, 0, 4, 4);	// CYAN
+    GIF_SetColor(4, 4, 0, 0);	// RED
+    GIF_SetColor(5, 4, 0, 4);	// MAGENTA
+    GIF_SetColor(6, 4, 3, 0);	// BROWN
+    GIF_SetColor(7, 4, 4, 4);	// LIGHTGREY
+    GIF_SetColor(8, 2, 2, 2);	// DARKGREY
+    GIF_SetColor(9, 0, 0, 7);	// LIGHTBLUE
+    GIF_SetColor(10, 0, 7, 0);	// LIGHTGREEN
+    GIF_SetColor(11, 0, 7, 7);	// LIGHTCYAN
+    GIF_SetColor(12, 7, 0, 0);	// LIGHTRED
+    GIF_SetColor(13, 7, 0, 7);	// LIGHTMAGENTA
+    GIF_SetColor(14, 7, 7, 0);	// YELLOW
+    GIF_SetColor(15, 7, 7, 7);	// WHITE
+    r = GIF_CompressImage(0, 17, ShotWidth, ShotHeight, ShotGetPixel);
+    if (r != GIF_OK)
+	LogMessage("GIF_CompressImage error %d\n", r);
+    r = GIF_Close();
+    LogMessage("GIF_Close returned %d\n", r);
 }
 
 
-static const char ColourCode[256] =
-{
-   0, 0, 0, 0,15, 0, 0, 0,  0, 0, 0, 0, 0, 0, 0, 0,
-   0, 0, 0, 0, 0, 0, 0, 0,  0, 0, 0, 0, 0, 0, 0, 0,
-   0, 0, 0, 0, 0, 0, 0, 0,  0, 0, 0, 0, 0, 0, 0, 0,
-   0, 0, 0, 0, 0, 0, 0, 0,  0, 0, 0, 0, 0, 0, 0, 0,
+static const char ColourCode[256] = {
+    0, 0, 0, 0, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
 
-   0, 0, 0, 0, 0, 0, 0, 0,  0, 0, 0, 0, 0, 0, 0, 0,
-   0, 0, 0, 0, 0, 0, 0, 0,  7, 0, 0, 0, 0, 0, 0, 0,
-   8, 0, 0, 0, 0, 0, 0, 0,  0, 0, 0, 0, 0, 0, 0, 0,
-  10, 0, 0, 0, 0, 0, 2, 0,  0, 0, 0, 0, 0, 0, 0, 0,
+    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+    0, 0, 0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0,
+    8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+    10, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0,
 
-   0, 0, 0, 0, 0, 0, 0, 0,  0, 0, 0, 0, 0, 0, 0, 0,
-   6, 0, 0, 0, 0, 0, 0, 0,  0, 0, 0, 0, 0, 0, 0, 0,
-   0, 0, 0, 0, 0, 0, 0, 0,  0, 0, 0, 0, 0, 0, 0, 0,
-  12, 0, 0, 0, 0, 0, 0, 4,  0, 0, 0, 0, 0, 0, 3, 0,
+    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+    6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+    12, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 3, 0,
 
-   0,11, 0, 0, 0, 9, 0, 0,  0, 0, 1, 0, 0, 0, 0, 0,
-   0, 0, 0, 0, 0, 0, 0,14,  0, 0, 0, 0, 0, 0, 0, 0,
-   0, 0, 0, 0, 0, 0, 0, 0,  0, 0, 0, 0, 0, 0, 0, 0,
-   0, 0, 0, 0, 0, 0, 0, 0,  0, 0,13, 0, 0, 5, 0, 0
+    0, 11, 0, 0, 0, 9, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0,
+    0, 0, 0, 0, 0, 0, 0, 14, 0, 0, 0, 0, 0, 0, 0, 0,
+    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 13, 0, 0, 5, 0, 0
 };
 
-static int ShotGetPixel (int x, int y)
+static int ShotGetPixel(int x, int y)
 {
-  // FIXME: I assume we're in 256 colours
-  return ColourCode[getpixel (x, y)];
+    // FIXME: I assume we're in 256 colours
+    return ColourCode[getpixel(x, y)];
 }
 #endif
-
--- a/src/selbox.cc	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/selbox.cc	Sat Sep 24 14:16:04 2011 +0300
@@ -35,90 +35,89 @@
 
 static const int flags_1st_corner_set = 1;
 static const int flags_2nd_corner_set = 1 << 1;
-static const int flags_displayed      = 1 << 2;
+static const int flags_displayed = 1 << 2;
 
 
 
-selbox_c::selbox_c (void)
+selbox_c::selbox_c(void)
 {
-  flags = 0;
+    flags = 0;
 }
 
 
-void selbox_c::set_1st_corner (int x, int y)
+void selbox_c::set_1st_corner(int x, int y)
 {
-  x1 = x;
-  y1 = y;
-  flags |= flags_1st_corner_set;
+    x1 = x;
+    y1 = y;
+    flags |= flags_1st_corner_set;
 }
 
 
-void selbox_c::set_2nd_corner (int x, int y)
+void selbox_c::set_2nd_corner(int x, int y)
 {
-  x2 = x;
-  y2 = y;
-  flags |= flags_2nd_corner_set;
+    x2 = x;
+    y2 = y;
+    flags |= flags_2nd_corner_set;
 }
 
 
-void selbox_c::get_corners (int *x1, int *y1, int *x2, int *y2)
+void selbox_c::get_corners(int *x1, int *y1, int *x2, int *y2)
 {
-  if (x1 != NULL)
-    *x1 = this->x1;
-  if (y1 != NULL)
-    *y1 = this->y1;
-  if (x2 != NULL)
-    *x2 = this->x2;
-  if (y2 != NULL)
-    *y2 = this->y2;
+    if (x1 != NULL)
+	*x1 = this->x1;
+    if (y1 != NULL)
+	*y1 = this->y1;
+    if (x2 != NULL)
+	*x2 = this->x2;
+    if (y2 != NULL)
+	*y2 = this->y2;
 }
 
 
-void selbox_c::unset_corners (void)
+void selbox_c::unset_corners(void)
 {
-  flags &= ~ (flags_1st_corner_set | flags_2nd_corner_set);
+    flags &= ~(flags_1st_corner_set | flags_2nd_corner_set);
 }
 
 
-void selbox_c::draw (void)
+void selbox_c::draw(void)
 {
-  if ((flags & flags_1st_corner_set) && (flags & flags_2nd_corner_set))
-  {
-    set_colour (CYAN);
-    SetDrawingMode (1);
-    DrawMapLine (x1, y1, x1, y2);
-    DrawMapLine (x1, y2, x2, y2);
-    DrawMapLine (x2, y2, x2, y1);
-    DrawMapLine (x2, y1, x1, y1);
-    SetDrawingMode (0);
-    /* Those are needed by undraw() */
-    x1_disp = x1;
-    y1_disp = y1;
-    x2_disp = x2;
-    y2_disp = y2;
-    flags |= flags_displayed;
-  }
+    if ((flags & flags_1st_corner_set) && (flags & flags_2nd_corner_set))
+    {
+	set_colour(CYAN);
+	SetDrawingMode(1);
+	DrawMapLine(x1, y1, x1, y2);
+	DrawMapLine(x1, y2, x2, y2);
+	DrawMapLine(x2, y2, x2, y1);
+	DrawMapLine(x2, y1, x1, y1);
+	SetDrawingMode(0);
+	/* Those are needed by undraw() */
+	x1_disp = x1;
+	y1_disp = y1;
+	x2_disp = x2;
+	y2_disp = y2;
+	flags |= flags_displayed;
+    }
 }
 
 
-void selbox_c::undraw (void)
+void selbox_c::undraw(void)
 {
-  if (flags & flags_displayed)
-  {
-    set_colour (CYAN);
-    SetDrawingMode (1);
-    DrawMapLine (x1_disp, y1_disp, x1_disp, y2_disp);
-    DrawMapLine (x1_disp, y2_disp, x2_disp, y2_disp);
-    DrawMapLine (x2_disp, y2_disp, x2_disp, y1_disp);
-    DrawMapLine (x2_disp, y1_disp, x1_disp, y1_disp);
-    SetDrawingMode (0);
-    flags &= ~ flags_displayed;
-  }
+    if (flags & flags_displayed)
+    {
+	set_colour(CYAN);
+	SetDrawingMode(1);
+	DrawMapLine(x1_disp, y1_disp, x1_disp, y2_disp);
+	DrawMapLine(x1_disp, y2_disp, x2_disp, y2_disp);
+	DrawMapLine(x2_disp, y2_disp, x2_disp, y1_disp);
+	DrawMapLine(x2_disp, y1_disp, x1_disp, y1_disp);
+	SetDrawingMode(0);
+	flags &= ~flags_displayed;
+    }
 }
 
 
-void selbox_c::clear (void)
+void selbox_c::clear(void)
 {
-  flags &= ~ flags_displayed;
+    flags &= ~flags_displayed;
 }
-
--- a/src/selbox.h	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/selbox.h	Sat Sep 24 14:16:04 2011 +0300
@@ -9,40 +9,41 @@
 #include "edwidget.h"
 
 
-class selbox_c : public edwidget_c
+class selbox_c:public edwidget_c
 {
-  public :
-
-    /* Methods used by edit_t */
-    selbox_c            ();
-    void set_1st_corner (int x, int y);
-    void set_2nd_corner (int x, int y);
-    void get_corners    (int *x1, int *y1, int *x2, int *y2);
-    void unset_corners  ();
+    public:
+	/* Methods used by edit_t */
+    selbox_c();
+    void set_1st_corner(int x, int y);
+    void set_2nd_corner(int x, int y);
+    void get_corners(int *x1, int *y1, int *x2, int *y2);
+    void unset_corners();
     /* Methods declared in edwidget_c */
-    void unset         ();
-    void draw          ();
-    void undraw        ();
+    void unset();
+    void draw();
+    void undraw();
 
-    int can_undraw ()
-      { return 1; }  // I have the ability to undraw myself
+    int can_undraw()
+    {
+	return 1;
+    }				// I have the ability to undraw myself
 
-    int need_to_clear ()
-      { return 0; }  // I know how to undraw myself.
-
-    void clear         ();
+    int need_to_clear()
+    {
+	return 0;
+    }				// I know how to undraw myself.
 
-  private :
+    void clear();
 
-    int x1;		/* Coordinates of the first corner */
+  private:
+
+    int x1;			/* Coordinates of the first corner */
     int y1;
-    int x2;		/* Coordinates of the second corner */
+    int x2;			/* Coordinates of the second corner */
     int y2;
-    int x1_disp;	/* x1 and y1 as they were last time draw() was called */
+    int x1_disp;		/* x1 and y1 as they were last time draw() was called */
     int y1_disp;
-    int x2_disp;	/* x2 and y2 as they were last time draw() was called */
+    int x2_disp;		/* x2 and y2 as they were last time draw() was called */
     int y2_disp;
     int flags;
 };
-
-
--- a/src/selectn.cc	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/selectn.cc	Sat Sep 24 14:16:04 2011 +0300
@@ -40,14 +40,14 @@
  *	FIXME change the identifier
  *	FIXME slow
  */
-bool IsSelected (SelPtr list, int objnum)
+bool IsSelected(SelPtr list, int objnum)
 {
-  SelPtr cur;
+    SelPtr cur;
 
-  for (cur = list; cur; cur = cur->next)
-    if (cur->objnum == objnum)
-      return true;
-  return false;
+    for (cur = list; cur; cur = cur->next)
+	if (cur->objnum == objnum)
+	    return true;
+    return false;
 }
 
 
@@ -56,15 +56,15 @@
  *
  *	FIXME change the identifier
  */
-void DumpSelection (SelPtr list)
+void DumpSelection(SelPtr list)
 {
-  int n;
-  SelPtr cur;
+    int n;
+    SelPtr cur;
 
-  printf ("Selection:");
-  for (n = 0, cur = list; cur; cur = cur->next, n++)
-    printf (" %d", cur->objnum);
-  printf ("  (%d)\n", n);
+    printf("Selection:");
+    for (n = 0, cur = list; cur; cur = cur->next, n++)
+	printf(" %d", cur->objnum);
+    printf("  (%d)\n", n);
 }
 
 
@@ -73,16 +73,16 @@
  *
  *	FIXME change the identifier
  */
-void SelectObject (SelPtr *list, int objnum)
+void SelectObject(SelPtr * list, int objnum)
 {
-  SelPtr cur;
+    SelPtr cur;
 
-  if (! is_obj (objnum))
-    fatal_error ("BUG: SelectObject called with %d", objnum);
-  cur = (SelPtr) GetMemory (sizeof (struct SelectionList));
-  cur->next = *list;
-  cur->objnum = objnum;
-  *list = cur;
+    if (!is_obj(objnum))
+	fatal_error("BUG: SelectObject called with %d", objnum);
+    cur = (SelPtr) GetMemory(sizeof(struct SelectionList));
+    cur->next = *list;
+    cur->objnum = objnum;
+    *list = cur;
 }
 
 
@@ -92,34 +92,34 @@
  *	If the object is not in the selection list, add it.  If
  *	it already is, remove it.
  */
-void select_unselect_obj (SelPtr *list, int objnum)
+void select_unselect_obj(SelPtr * list, int objnum)
 {
-SelPtr cur;
-SelPtr prev;
+    SelPtr cur;
+    SelPtr prev;
 
-if (! is_obj (objnum))
-  fatal_error ("s/u_obj called with %d", objnum);
-for (prev = NULL, cur = *list; cur != NULL; prev = cur, cur = cur->next)
-  // Already selected: unselect it.
-  if (cur->objnum == objnum)
-  {
-    if (prev != NULL)
-      prev->next = cur->next;
-    else
-      *list = cur->next;
-    FreeMemory (cur);
-    if (prev != NULL)
-      cur = prev->next;
-    else
-      cur = (SelPtr) NULL;
-    return;
-  }
+    if (!is_obj(objnum))
+	fatal_error("s/u_obj called with %d", objnum);
+    for (prev = NULL, cur = *list; cur != NULL; prev = cur, cur = cur->next)
+	// Already selected: unselect it.
+	if (cur->objnum == objnum)
+	{
+	    if (prev != NULL)
+		prev->next = cur->next;
+	    else
+		*list = cur->next;
+	    FreeMemory(cur);
+	    if (prev != NULL)
+		cur = prev->next;
+	    else
+		cur = (SelPtr) NULL;
+	    return;
+	}
 
-  // Not selected: select it.
-  cur = (SelPtr) GetMemory (sizeof (struct SelectionList));
-  cur->next = *list;
-  cur->objnum = objnum;
-  *list = cur;
+    // Not selected: select it.
+    cur = (SelPtr) GetMemory(sizeof(struct SelectionList));
+    cur->next = *list;
+    cur->objnum = objnum;
+    *list = cur;
 }
 
 
@@ -128,34 +128,34 @@
  *
  *	FIXME change the identifier
  */
-void UnSelectObject (SelPtr *list, int objnum)
+void UnSelectObject(SelPtr * list, int objnum)
 {
-  SelPtr cur, prev;
+    SelPtr cur, prev;
 
-  if (! is_obj (objnum))
-    fatal_error ("BUG: UnSelectObject called with %d", objnum);
-  prev = 0;
-  cur = *list;
-  while (cur)
-  {
-    if (cur->objnum == objnum)
+    if (!is_obj(objnum))
+	fatal_error("BUG: UnSelectObject called with %d", objnum);
+    prev = 0;
+    cur = *list;
+    while (cur)
     {
-      if (prev)
-	prev->next = cur->next;
-      else
-	*list = cur->next;
-      FreeMemory (cur);
-      if (prev)
-	cur = prev->next;
-      else
-	cur = 0;
+	if (cur->objnum == objnum)
+	{
+	    if (prev)
+		prev->next = cur->next;
+	    else
+		*list = cur->next;
+	    FreeMemory(cur);
+	    if (prev)
+		cur = prev->next;
+	    else
+		cur = 0;
+	}
+	else
+	{
+	    prev = cur;
+	    cur = cur->next;
+	}
     }
-    else
-    {
-      prev = cur;
-      cur = cur->next;
-    }
-  }
 }
 
 
@@ -164,18 +164,18 @@
  *
  *	FIXME change the identifier
  */
-void ForgetSelection (SelPtr *list)
+void ForgetSelection(SelPtr * list)
 {
-  SelPtr cur, prev;
+    SelPtr cur, prev;
 
-  cur = *list;
-  while (cur)
-  {
-    prev = cur;
-    cur = cur->next;
-    FreeMemory (prev);
-  }
-  *list = 0;
+    cur = *list;
+    while (cur)
+    {
+	prev = cur;
+	cur = cur->next;
+	FreeMemory(prev);
+    }
+    *list = 0;
 }
 
 
@@ -185,15 +185,15 @@
  *	The bit vector has <bitvec_size> elements. It's up to
  *	the caller to delete the new bit vector after use.
  */
-bitvec_c *list_to_bitvec (SelPtr list, size_t bitvec_size)
+bitvec_c *list_to_bitvec(SelPtr list, size_t bitvec_size)
 {
-  SelPtr cur;
-  bitvec_c *bitvec;
+    SelPtr cur;
+    bitvec_c *bitvec;
 
-  bitvec = new bitvec_c (bitvec_size);
-  for (cur = list; cur; cur = cur->next)
-    bitvec->set (cur->objnum);
-  return bitvec;
+    bitvec = new bitvec_c(bitvec_size);
+    for (cur = list; cur; cur = cur->next)
+	bitvec->set(cur->objnum);
+    return bitvec;
 }
 
 
@@ -204,12 +204,11 @@
  *	(i.e. item N in the bitvec is inserted before item N+1).
  *	It's up to the caller to delete the new list after use.
  */
-SelPtr bitvec_to_list (const bitvec_c &b)
+SelPtr bitvec_to_list(const bitvec_c & b)
 {
-  SelPtr list = 0;
-  for (size_t n = 0; n < b.nelements (); n++)
-    if (b.get (n))
-      SelectObject (&list, n);
-  return list;
+    SelPtr list = 0;
+    for (size_t n = 0; n < b.nelements(); n++)
+	if (b.get(n))
+	    SelectObject(&list, n);
+    return list;
 }
-
--- a/src/selectn.h	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/selectn.h	Sat Sep 24 14:16:04 2011 +0300
@@ -5,7 +5,7 @@
  */
 
 
-#ifndef YH_SELECTN  /* DO NOT INSERT ANYTHING BEFORE THIS LINE */
+#ifndef YH_SELECTN		/* DO NOT INSERT ANYTHING BEFORE THIS LINE */
 #define YH_SELECTN
 
 
@@ -16,18 +16,18 @@
 typedef struct SelectionList *SelPtr;
 struct SelectionList
 {
-  SelPtr next;				// Next in list
-  int objnum;				// Object number
+    SelPtr next;		// Next in list
+    int objnum;			// Object number
 };
 
-bool IsSelected (SelPtr, int);
-void DumpSelection (SelPtr list);
-void SelectObject (SelPtr *, int);
-void select_unselect_obj (SelPtr *list, int objnum);
-void UnSelectObject (SelPtr *, int);
-void ForgetSelection (SelPtr *);
-bitvec_c *list_to_bitvec (SelPtr list, size_t bitvec_size);
-SelPtr bitvec_to_list (const bitvec_c &b);
+bool IsSelected(SelPtr, int);
+void DumpSelection(SelPtr list);
+void SelectObject(SelPtr *, int);
+void select_unselect_obj(SelPtr * list, int objnum);
+void UnSelectObject(SelPtr *, int);
+void ForgetSelection(SelPtr *);
+bitvec_c *list_to_bitvec(SelPtr list, size_t bitvec_size);
+SelPtr bitvec_to_list(const bitvec_c & b);
 
 
-#endif  /* DO NOT ADD ANYTHING AFTER THIS LINE */
+#endif /* DO NOT ADD ANYTHING AFTER THIS LINE */
--- a/src/selpath.cc	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/selpath.cc	Sat Sep 24 14:16:04 2011 +0300
@@ -36,16 +36,14 @@
 #include "wstructs.h"
 
 
-static void select_linedefs_in_half_path (bitvec_c &sel,
-    bitvec_c &ldseen,
-    int linedef_no,
-    int vertex_no,
-    sel_op_t mode);
-static void select_1s_linedefs_in_half_path (bitvec_c &sel,
-    bitvec_c &ldseen,
-    int linedef_no,
-    int vertex_no,
-    sel_op_t mode);
+static void select_linedefs_in_half_path(bitvec_c & sel,
+					 bitvec_c & ldseen,
+					 int linedef_no,
+					 int vertex_no, sel_op_t mode);
+static void select_1s_linedefs_in_half_path(bitvec_c & sel,
+					    bitvec_c & ldseen,
+					    int linedef_no,
+					    int vertex_no, sel_op_t mode);
 
 
 /*
@@ -57,23 +55,23 @@
  *	removed if it was already in the selection, otherwise
  *	added.
  */
-void select_linedefs_path (SelPtr *list, int linedef_no, sel_op_t mode)
+void select_linedefs_path(SelPtr * list, int linedef_no, sel_op_t mode)
 {
-bitvec_c *ldsel = list_to_bitvec (*list, NumLineDefs);
-bitvec_c ldseen (NumLineDefs);  // Linedef already seen ?
+    bitvec_c *ldsel = list_to_bitvec(*list, NumLineDefs);
+    bitvec_c ldseen(NumLineDefs);	// Linedef already seen ?
 
-if (! is_obj (linedef_no))  // Sanity check
-   fatal_error ("select_linedef_path called with bad linedef_no=%d",
-      linedef_no);
+    if (!is_obj(linedef_no))	// Sanity check
+	fatal_error("select_linedef_path called with bad linedef_no=%d",
+		    linedef_no);
 
-LDPtr ld = LineDefs + linedef_no;
-ldsel->frob (linedef_no, (bitvec_op_t) mode);
-ldseen.set (linedef_no);
-select_linedefs_in_half_path (*ldsel, ldseen, linedef_no, ld->start, mode);
-select_linedefs_in_half_path (*ldsel, ldseen, linedef_no, ld->end, mode);
-ForgetSelection (list);
-*list = bitvec_to_list (*ldsel);
-delete ldsel;
+    LDPtr ld = LineDefs + linedef_no;
+    ldsel->frob(linedef_no, (bitvec_op_t) mode);
+    ldseen.set(linedef_no);
+    select_linedefs_in_half_path(*ldsel, ldseen, linedef_no, ld->start, mode);
+    select_linedefs_in_half_path(*ldsel, ldseen, linedef_no, ld->end, mode);
+    ForgetSelection(list);
+    *list = bitvec_to_list(*ldsel);
+    delete ldsel;
 }
 
 
@@ -86,51 +84,50 @@
  *	added to the list sel and the function recursively calls
  *	itself on the other vertex of that linedef.
  */
-static void select_linedefs_in_half_path (bitvec_c &ldsel,
-    bitvec_c &ldseen,
-    int linedef_no,
-    int vertex_no,
-    sel_op_t mode)
+static void select_linedefs_in_half_path(bitvec_c & ldsel,
+					 bitvec_c & ldseen,
+					 int linedef_no,
+					 int vertex_no, sel_op_t mode)
 {
-  int next_linedef_no = OBJ_NO_NONE;
-  int next_vertex_no = OBJ_NO_NONE;
+    int next_linedef_no = OBJ_NO_NONE;
+    int next_vertex_no = OBJ_NO_NONE;
 
-  // Look for the next linedef in the path. It's the
-  // linedef that uses vertex vertex_no and is not
-  // linedef_no.
-  for (int n = 0; n < NumLineDefs; n++)
-  {
-    if (n == linedef_no)
-      continue;
-    if (LineDefs[n].start == vertex_no)
+    // Look for the next linedef in the path. It's the
+    // linedef that uses vertex vertex_no and is not
+    // linedef_no.
+    for (int n = 0; n < NumLineDefs; n++)
     {
-      if (is_obj (next_linedef_no))
-	return;  // There is a fork in the path. Stop here.
-      // Continue search at the other end of the linedef
-      next_vertex_no = LineDefs[n].end;
-      next_linedef_no = n;
-    }
-    if (LineDefs[n].end == vertex_no)
-    {
-      if (is_obj (next_linedef_no))
-	return;  // There is a fork in the path. Stop here.
-      // Continue search at the other end of the linedef
-      next_vertex_no = LineDefs[n].start;
-      next_linedef_no = n;
+	if (n == linedef_no)
+	    continue;
+	if (LineDefs[n].start == vertex_no)
+	{
+	    if (is_obj(next_linedef_no))
+		return;		// There is a fork in the path. Stop here.
+	    // Continue search at the other end of the linedef
+	    next_vertex_no = LineDefs[n].end;
+	    next_linedef_no = n;
+	}
+	if (LineDefs[n].end == vertex_no)
+	{
+	    if (is_obj(next_linedef_no))
+		return;		// There is a fork in the path. Stop here.
+	    // Continue search at the other end of the linedef
+	    next_vertex_no = LineDefs[n].start;
+	    next_linedef_no = n;
+	}
     }
-  }
-  if (! is_obj (next_linedef_no))  // None ? Reached end of path.
-    return;
+    if (!is_obj(next_linedef_no))	// None ? Reached end of path.
+	return;
 
-  // Already seen the next linedef ? The path must be
-  // closed. No need to do like the Dupondt.
-  if (ldseen.get (next_linedef_no))
-    return;
+    // Already seen the next linedef ? The path must be
+    // closed. No need to do like the Dupondt.
+    if (ldseen.get(next_linedef_no))
+	return;
 
-  ldsel.frob (next_linedef_no, (bitvec_op_t) mode);
-  ldseen.set (next_linedef_no);
-  select_linedefs_in_half_path (ldsel, ldseen, next_linedef_no, next_vertex_no,
-      mode);
+    ldsel.frob(next_linedef_no, (bitvec_op_t) mode);
+    ldseen.set(next_linedef_no);
+    select_linedefs_in_half_path(ldsel, ldseen, next_linedef_no,
+				 next_vertex_no, mode);
 }
 
 
@@ -144,27 +141,29 @@
  *	removed if it was already in the selection, otherwise
  *	added.
  */
-void select_1s_linedefs_path (SelPtr *list, int linedef_no, sel_op_t mode)
+void select_1s_linedefs_path(SelPtr * list, int linedef_no, sel_op_t mode)
 {
-bitvec_c *ldsel = list_to_bitvec (*list, NumLineDefs);
-bitvec_c ldseen (NumLineDefs);  // Linedef already seen ?
+    bitvec_c *ldsel = list_to_bitvec(*list, NumLineDefs);
+    bitvec_c ldseen(NumLineDefs);	// Linedef already seen ?
 
-if (! is_obj (linedef_no))  // Sanity check
-   fatal_error ("select_linedef_path called with bad linedef_no=%d",
-      linedef_no);
+    if (!is_obj(linedef_no))	// Sanity check
+	fatal_error("select_linedef_path called with bad linedef_no=%d",
+		    linedef_no);
 
-LDPtr ld = LineDefs + linedef_no;
-if (! is_obj (ld->sidedef1)  // The first linedef is not single-sided. Quit.
-    || is_obj (ld->sidedef2))
-  goto byebye;
-ldsel->frob (linedef_no, (bitvec_op_t) mode);
-ldseen.set (linedef_no);
-select_1s_linedefs_in_half_path (*ldsel, ldseen, linedef_no, ld->start, mode);
-select_1s_linedefs_in_half_path (*ldsel, ldseen, linedef_no, ld->end, mode);
-ForgetSelection (list);
-*list = bitvec_to_list (*ldsel);
-byebye:
-delete ldsel;
+    LDPtr ld = LineDefs + linedef_no;
+    if (!is_obj(ld->sidedef1)	// The first linedef is not single-sided. Quit.
+	|| is_obj(ld->sidedef2))
+	goto byebye;
+    ldsel->frob(linedef_no, (bitvec_op_t) mode);
+    ldseen.set(linedef_no);
+    select_1s_linedefs_in_half_path(*ldsel, ldseen, linedef_no, ld->start,
+				    mode);
+    select_1s_linedefs_in_half_path(*ldsel, ldseen, linedef_no, ld->end,
+				    mode);
+    ForgetSelection(list);
+    *list = bitvec_to_list(*ldsel);
+  byebye:
+    delete ldsel;
 }
 
 
@@ -173,55 +172,50 @@
  *	Like select_linedefs_in_half_path() except that only
  *	single-sided linedefs are selected.
  */
-static void select_1s_linedefs_in_half_path (bitvec_c &ldsel,
-    bitvec_c &ldseen,
-    int linedef_no,
-    int vertex_no,
-    sel_op_t mode)
+static void select_1s_linedefs_in_half_path(bitvec_c & ldsel,
+					    bitvec_c & ldseen,
+					    int linedef_no,
+					    int vertex_no, sel_op_t mode)
 {
-  int next_linedef_no = OBJ_NO_NONE;
-  int next_vertex_no = OBJ_NO_NONE;
+    int next_linedef_no = OBJ_NO_NONE;
+    int next_vertex_no = OBJ_NO_NONE;
 
-  // Look for the next linedef in the path. It's the
-  // linedef that uses vertex vertex_no and is not
-  // linedef_no.
-  for (int n = 0; n < NumLineDefs; n++)
-  {
-    if (n == linedef_no)
-      continue;
-    if (LineDefs[n].start == vertex_no
-	&& is_obj (LineDefs[n].sidedef1)
-	&& ! is_obj (LineDefs[n].sidedef2))
+    // Look for the next linedef in the path. It's the
+    // linedef that uses vertex vertex_no and is not
+    // linedef_no.
+    for (int n = 0; n < NumLineDefs; n++)
     {
-      if (is_obj (next_linedef_no))
-	return;  // There is a fork in the path. Stop here.
-      // Continue search at the other end of the linedef
-      next_vertex_no = LineDefs[n].end;
-      next_linedef_no = n;
+	if (n == linedef_no)
+	    continue;
+	if (LineDefs[n].start == vertex_no
+	    && is_obj(LineDefs[n].sidedef1) && !is_obj(LineDefs[n].sidedef2))
+	{
+	    if (is_obj(next_linedef_no))
+		return;		// There is a fork in the path. Stop here.
+	    // Continue search at the other end of the linedef
+	    next_vertex_no = LineDefs[n].end;
+	    next_linedef_no = n;
+	}
+	if (LineDefs[n].end == vertex_no
+	    && is_obj(LineDefs[n].sidedef1) && !is_obj(LineDefs[n].sidedef2))
+	{
+	    if (is_obj(next_linedef_no))
+		return;		// There is a fork in the path. Stop here.
+	    // Continue search at the other end of the linedef
+	    next_vertex_no = LineDefs[n].start;
+	    next_linedef_no = n;
+	}
     }
-    if (LineDefs[n].end == vertex_no
-	&& is_obj (LineDefs[n].sidedef1)
-	&& ! is_obj (LineDefs[n].sidedef2))
-    {
-      if (is_obj (next_linedef_no))
-	return;  // There is a fork in the path. Stop here.
-      // Continue search at the other end of the linedef
-      next_vertex_no = LineDefs[n].start;
-      next_linedef_no = n;
-    }
-  }
-  if (! is_obj (next_linedef_no))  // None ? Reached end of path.
-    return;
+    if (!is_obj(next_linedef_no))	// None ? Reached end of path.
+	return;
 
-  // Already seen the next linedef ? The path must be
-  // closed. No need to do like the Dupondt.
-  if (ldseen.get (next_linedef_no))
-    return;
+    // Already seen the next linedef ? The path must be
+    // closed. No need to do like the Dupondt.
+    if (ldseen.get(next_linedef_no))
+	return;
 
-  ldsel.frob (next_linedef_no, (bitvec_op_t) mode);
-  ldseen.set (next_linedef_no);
-  select_1s_linedefs_in_half_path (ldsel, ldseen, next_linedef_no,
-      next_vertex_no, mode);
+    ldsel.frob(next_linedef_no, (bitvec_op_t) mode);
+    ldseen.set(next_linedef_no);
+    select_1s_linedefs_in_half_path(ldsel, ldseen, next_linedef_no,
+				    next_vertex_no, mode);
 }
-
-
--- a/src/selpath.h	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/selpath.h	Sat Sep 24 14:16:04 2011 +0300
@@ -5,7 +5,5 @@
  */
 
 
-void select_linedefs_path (SelPtr *list, int linedef_no, sel_op_t mode);
-void select_1s_linedefs_path (SelPtr *list, int linedef_no, sel_op_t mode);
-
-
+void select_linedefs_path(SelPtr * list, int linedef_no, sel_op_t mode);
+void select_1s_linedefs_path(SelPtr * list, int linedef_no, sel_op_t mode);
--- a/src/selrect.cc	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/selrect.cc	Sat Sep 24 14:16:04 2011 +0300
@@ -38,110 +38,109 @@
    select all objects inside a given box
 */
 
-void SelectObjectsInBox (SelPtr *list, int objtype, int x0, int y0, int x1, int y1) /* SWAP! */
+void SelectObjectsInBox(SelPtr * list, int objtype, int x0, int y0, int x1, int y1)	/* SWAP! */
 {
-int n, m;
+    int n, m;
 
-if (x1 < x0)
-   {
-   n = x0;
-   x0 = x1;
-   x1 = n;
-   }
-if (y1 < y0)
-   {
-   n = y0;
-   y0 = y1;
-   y1 = n;
-   }
+    if (x1 < x0)
+    {
+	n = x0;
+	x0 = x1;
+	x1 = n;
+    }
+    if (y1 < y0)
+    {
+	n = y0;
+	y0 = y1;
+	y1 = n;
+    }
 
-switch (objtype)
-   {
-   case OBJ_THINGS:
-      for (n = 0; n < NumThings; n++)
-	 if (Things[n].xpos >= x0 && Things[n].xpos <= x1
-	  && Things[n].ypos >= y0 && Things[n].ypos <= y1)
-            select_unselect_obj (list, n);
-      break;
-   case OBJ_VERTICES:
-      for (n = 0; n < NumVertices; n++)
-	 if (Vertices[n].x >= x0 && Vertices[n].x <= x1
-	  && Vertices[n].y >= y0 && Vertices[n].y <= y1)
-            select_unselect_obj (list, n);
-      break;
-   case OBJ_LINEDEFS:
-      for (n = 0; n < NumLineDefs; n++)
-	 {
-	 /* the two ends of the line must be in the box */
-	 m = LineDefs[n].start;
-	 if (Vertices[m].x < x0 || Vertices[m].x > x1
-	  || Vertices[m].y < y0 || Vertices[m].y > y1)
-	    continue;
-	 m = LineDefs[n].end;
-	 if (Vertices[m].x < x0 || Vertices[m].x > x1
-	  || Vertices[m].y < y0 || Vertices[m].y > y1)
-	    continue;
-         select_unselect_obj (list, n);
-	 }
-      break;
-   case OBJ_SECTORS:
-      {
-      signed char *sector_status;
-      LDPtr ld;
+    switch (objtype)
+    {
+    case OBJ_THINGS:
+	for (n = 0; n < NumThings; n++)
+	    if (Things[n].xpos >= x0 && Things[n].xpos <= x1
+		&& Things[n].ypos >= y0 && Things[n].ypos <= y1)
+		select_unselect_obj(list, n);
+	break;
+    case OBJ_VERTICES:
+	for (n = 0; n < NumVertices; n++)
+	    if (Vertices[n].x >= x0 && Vertices[n].x <= x1
+		&& Vertices[n].y >= y0 && Vertices[n].y <= y1)
+		select_unselect_obj(list, n);
+	break;
+    case OBJ_LINEDEFS:
+	for (n = 0; n < NumLineDefs; n++)
+	{
+	    /* the two ends of the line must be in the box */
+	    m = LineDefs[n].start;
+	    if (Vertices[m].x < x0 || Vertices[m].x > x1
+		|| Vertices[m].y < y0 || Vertices[m].y > y1)
+		continue;
+	    m = LineDefs[n].end;
+	    if (Vertices[m].x < x0 || Vertices[m].x > x1
+		|| Vertices[m].y < y0 || Vertices[m].y > y1)
+		continue;
+	    select_unselect_obj(list, n);
+	}
+	break;
+    case OBJ_SECTORS:
+	{
+	    signed char *sector_status;
+	    LDPtr ld;
 
-      sector_status = (signed char *) GetMemory (NumSectors);
-      memset (sector_status, 0, NumSectors);
-      for (n = 0, ld = LineDefs; n < NumLineDefs; n++, ld++)
-         {
-         VPtr v1, v2;
-         int s1, s2;
+	    sector_status = (signed char *) GetMemory(NumSectors);
+	    memset(sector_status, 0, NumSectors);
+	    for (n = 0, ld = LineDefs; n < NumLineDefs; n++, ld++)
+	    {
+		VPtr v1, v2;
+		int s1, s2;
 
-         v1 = Vertices + ld->start;
-         v2 = Vertices + ld->end;
+		v1 = Vertices + ld->start;
+		v2 = Vertices + ld->end;
 
-         // Get the numbers of the sectors on both sides of the linedef
-	 if (is_sidedef (ld->sidedef1)
-	  && is_sector (SideDefs[ld->sidedef1].sector))
-	    s1 = SideDefs[ld->sidedef1].sector;
-	 else
-	    s1 = OBJ_NO_NONE;
-	 if (is_sidedef (ld->sidedef2)
-	  && is_sector (SideDefs[ld->sidedef2].sector))
-	    s2 = SideDefs[ld->sidedef2].sector;
-	 else
-	    s2 = OBJ_NO_NONE;
+		// Get the numbers of the sectors on both sides of the linedef
+		if (is_sidedef(ld->sidedef1)
+		    && is_sector(SideDefs[ld->sidedef1].sector))
+		    s1 = SideDefs[ld->sidedef1].sector;
+		else
+		    s1 = OBJ_NO_NONE;
+		if (is_sidedef(ld->sidedef2)
+		    && is_sector(SideDefs[ld->sidedef2].sector))
+		    s2 = SideDefs[ld->sidedef2].sector;
+		else
+		    s2 = OBJ_NO_NONE;
 
-         // The linedef is entirely within bounds.
-         // The sectors it touches _might_ be within bounds too.
-         if (v1->x >= x0 && v1->x <= x1
-          && v1->y >= y0 && v1->y <= y1
-          && v2->x >= x0 && v2->x <= x1
-          && v2->y >= y0 && v2->y <= y1)
-            {
-            if (is_sector (s1) && sector_status[s1] >= 0)
-               sector_status[s1] = 1;
-            if (is_sector (s2) && sector_status[s2] >= 0)
-               sector_status[s2] = 1;
-            }
+		// The linedef is entirely within bounds.
+		// The sectors it touches _might_ be within bounds too.
+		if (v1->x >= x0 && v1->x <= x1
+		    && v1->y >= y0 && v1->y <= y1
+		    && v2->x >= x0 && v2->x <= x1
+		    && v2->y >= y0 && v2->y <= y1)
+		{
+		    if (is_sector(s1) && sector_status[s1] >= 0)
+			sector_status[s1] = 1;
+		    if (is_sector(s2) && sector_status[s2] >= 0)
+			sector_status[s2] = 1;
+		}
 
-         // It's not. The sectors it touches _can't_ be within bounds.
-         else
-            {
-            if (is_sector (s1))
-               sector_status[s1] = -1;
-            if (is_sector (s2))
-               sector_status[s2] = -1;
-            }
-         }
+		// It's not. The sectors it touches _can't_ be within bounds.
+		else
+		{
+		    if (is_sector(s1))
+			sector_status[s1] = -1;
+		    if (is_sector(s2))
+			sector_status[s2] = -1;
+		}
+	    }
 
-      // Now select all the sectors we found to be within bounds
-      ForgetSelection (list);
-      for (n = 0; n < NumSectors; n++)
-         if (sector_status[n] > 0)
-            SelectObject (list, n);
-      FreeMemory (sector_status);
-      }
-      break;
-   }
+	    // Now select all the sectors we found to be within bounds
+	    ForgetSelection(list);
+	    for (n = 0; n < NumSectors; n++)
+		if (sector_status[n] > 0)
+		    SelectObject(list, n);
+	    FreeMemory(sector_status);
+	}
+	break;
+    }
 }
-
--- a/src/serialnum.cc	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/serialnum.cc	Sat Sep 24 14:16:04 2011 +0300
@@ -32,48 +32,46 @@
 #include "serialnum.h"
 
 
-Serial_num::Serial_num ()
+Serial_num::Serial_num()
 {
-  serial_no      = 0;
-  serial_is_used = false;
+    serial_no = 0;
+    serial_is_used = false;
 }
 
 
 /*
  *	stale - call this to check whether a serial number has become stale
  */
-bool Serial_num::outdated (const serial_num_t& token)
+bool Serial_num::outdated(const serial_num_t & token)
 {
-  return token != serial_no;
+    return token != serial_no;
 }
 
 
 /*
  *	update - get the revision number
  */
-void Serial_num::update (serial_num_t& token)
+void Serial_num::update(serial_num_t & token)
 {
-  serial_is_used = true;
-  token          = serial_no;
+    serial_is_used = true;
+    token = serial_no;
 }
 
 
 /*
  *	bump - call this to increment the revision number
  */
-void Serial_num::bump ()
+void Serial_num::bump()
 {
-  /* If no one uses the current serial number, bumping it would
-     be a waste of S/N space. */
-  if (! serial_is_used)
-    return;
+    /* If no one uses the current serial number, bumping it would
+       be a waste of S/N space. */
+    if (!serial_is_used)
+	return;
 
-  serial_no++;
-  serial_is_used = false;
-  if (serial_no == 0)  // Extremely unlikely to ever happen
-  {
-    nf_bug ("Serial_num(%p)::serial_no wrapped around", this);
-  }
+    serial_no++;
+    serial_is_used = false;
+    if (serial_no == 0)		// Extremely unlikely to ever happen
+    {
+	nf_bug("Serial_num(%p)::serial_no wrapped around", this);
+    }
 }
-
-
--- a/src/serialnum.h	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/serialnum.h	Sat Sep 24 14:16:04 2011 +0300
@@ -28,7 +28,7 @@
 */
 
 
-#ifndef YH_SERIALNUM  /* DO NOT INSERT ANYTHING BEFORE THIS LINE */
+#ifndef YH_SERIALNUM		/* DO NOT INSERT ANYTHING BEFORE THIS LINE */
 #define YH_SERIALNUM
 
 
@@ -37,15 +37,13 @@
 
 class Serial_num
 {
-  public :
-    Serial_num ();
-    void         update (serial_num_t& token);
-    bool         outdated (const serial_num_t& token);
-    void         bump ();
-  private :
-    serial_num_t serial_no;
-    bool         serial_is_used;
+    public: Serial_num();
+    void update(serial_num_t & token);
+    bool outdated(const serial_num_t & token);
+    void bump();
+      private: serial_num_t serial_no;
+    bool serial_is_used;
 };
 
 
-#endif  /* DO NOT ADD ANYTHING AFTER THIS LINE */
+#endif /* DO NOT ADD ANYTHING AFTER THIS LINE */
--- a/src/spot.h	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/spot.h	Sat Sep 24 14:16:04 2011 +0300
@@ -31,54 +31,74 @@
 #include "gfx.h"
 
 
-class spot_c : public edwidget_c
+class spot_c:public edwidget_c
 {
-  public :
-
-    /*
-     *	Specific to this class
-     */
-    spot_c () { visible = 0; visible_disp = 0; }
-    void set (int x, int y) { this->x = x; this->y = y; visible = 1; }
+    public:
+	/*
+	 *  Specific to this class
+	 */
+    spot_c()
+    {
+	visible = 0;
+	visible_disp = 0;
+    }
+    void set(int x, int y)
+    {
+	this->x = x;
+	this->y = y;
+	visible = 1;
+    }
 
     /*
-     *	Inherited from edwidget_c
+     *  Inherited from edwidget_c
      */
-    void unset () { visible = 0; }
+    void unset()
+    {
+	visible = 0;
+    }
 
-    void draw ()
+    void draw()
     {
-      if (visible && (! visible_disp || x_disp != x || y_disp != y))
-      {
-	SetDrawingMode (1);
-	push_colour (LIGHTGREEN);
-	draw_map_point (x, y);
-	pop_colour ();
-	SetDrawingMode (0);
-	visible_disp = 1;
-	x_disp = x;
-	y_disp = y;
-      }
+	if (visible && (!visible_disp || x_disp != x || y_disp != y))
+	{
+	    SetDrawingMode(1);
+	    push_colour(LIGHTGREEN);
+	    draw_map_point(x, y);
+	    pop_colour();
+	    SetDrawingMode(0);
+	    visible_disp = 1;
+	    x_disp = x;
+	    y_disp = y;
+	}
     }
 
-    void undraw ()
+    void undraw()
     {
-      if (visible_disp)
-      {
-	SetDrawingMode (1);
-	push_colour (LIGHTGREEN);
-	draw_map_point (x_disp, y_disp);
-	pop_colour ();
-	SetDrawingMode (0);
-	visible_disp = 0;
-      }
+	if (visible_disp)
+	{
+	    SetDrawingMode(1);
+	    push_colour(LIGHTGREEN);
+	    draw_map_point(x_disp, y_disp);
+	    pop_colour();
+	    SetDrawingMode(0);
+	    visible_disp = 0;
+	}
     }
 
-    int can_undraw () { return 1; }
-    int need_to_clear () { return 0; }
-    void clear () { visible_disp = 0; }
+    int can_undraw()
+    {
+	return 1;
+    }
+    int need_to_clear()
+    {
+	return 0;
+    }
+    void clear()
+    {
+	visible_disp = 0;
+    }
 
-  private :
+  private:
     int visible;
     int visible_disp;
     int x;
@@ -86,4 +106,3 @@
     int x_disp;
     int y_disp;
 };
-
--- a/src/spritdir.cc	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/spritdir.cc	Sat Sep 24 14:16:04 2011 +0300
@@ -43,24 +43,23 @@
  *      lump by alphabetical order whose name begins with
  *      <name>. If not found, set loc.wad to 0.
  */
-void Sprite_dir::loc_by_root (const char *name, Lump_loc& loc)
+void Sprite_dir::loc_by_root(const char *name, Lump_loc & loc)
 {
-  if (dependency->outdated ())
-    refresh ();
+    if (dependency->outdated())
+	refresh();
 
-  /* Caller asked for same lump twice in a row. Save us a second
-     search. */
-  if (have_prev && ! y_strnicmp (name, name_prev, WAD_NAME))
-  {
-    loc = loc_prev;
-    return;
-  }
+    /* Caller asked for same lump twice in a row. Save us a second
+       search. */
+    if (have_prev && !y_strnicmp(name, name_prev, WAD_NAME))
+    {
+	loc = loc_prev;
+	return;
+    }
 
-  Lump_map::const_iterator i = lump_map.lower_bound (name);
-  have_prev = true;
-  if (i == lump_map.end () || y_strnicmp (name, i->first.name, strlen (name)))
-    loc.wad = loc_prev.wad = 0;
-  else
-    loc = loc_prev = i->second;
+    Lump_map::const_iterator i = lump_map.lower_bound(name);
+    have_prev = true;
+    if (i == lump_map.end() || y_strnicmp(name, i->first.name, strlen(name)))
+	loc.wad = loc_prev.wad = 0;
+    else
+	loc = loc_prev = i->second;
 }
-
--- a/src/spritdir.h	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/spritdir.h	Sat Sep 24 14:16:04 2011 +0300
@@ -28,7 +28,7 @@
 */
 
 
-#ifndef YH_SPRITDIR  /* DO NOT INSERT ANYTHING BEFORE THIS LINE */
+#ifndef YH_SPRITDIR		/* DO NOT INSERT ANYTHING BEFORE THIS LINE */
 #define YH_SPRITDIR
 
 
@@ -44,12 +44,13 @@
  */
 
 
-class Sprite_dir : public Lump_dir
+class Sprite_dir:public Lump_dir
 {
-  public :
-    Sprite_dir (MDirPtr *md, Serial_num *sn) : Lump_dir (md, 'S', sn) { }
-    void loc_by_root (const char *name, Lump_loc& loc);
+    public: Sprite_dir(MDirPtr * md, Serial_num * sn):Lump_dir(md, 'S', sn)
+    {
+    }
+    void loc_by_root(const char *name, Lump_loc & loc);
 };
 
 
-#endif  /* DO NOT ADD ANYTHING AFTER THIS LINE */
+#endif /* DO NOT ADD ANYTHING AFTER THIS LINE */
--- a/src/sticker.cc	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/sticker.cc	Sat Sep 24 14:16:04 2011 +0300
@@ -29,7 +29,7 @@
 
 #include "yadex.h"
 #include <X11/Xlib.h>
-#include <X11/Xutil.h>  // XDestroyImage
+#include <X11/Xutil.h>		// XDestroyImage
 #include "gcolour2.h"
 #include "gcolour3.h"
 #include "gfx.h"
@@ -39,175 +39,175 @@
 
 class Sticker_priv
 {
-  public :
-    Sticker_priv ();
-    ~Sticker_priv ();
-    void clear ();
-    void load (const Img &img, bool opaque);
-    XImage *make_ximage (const Img& img);
-    XImage *make_bitmap (const Img& img);
+    public:Sticker_priv();
+    ~Sticker_priv();
+    void clear();
+    void load(const Img & img, bool opaque);
+    XImage *make_ximage(const Img & img);
+    XImage *make_bitmap(const Img & img);
     bool opaque;
     bool has_data;
-    int  width;
-    int  height;
-    XImage *ximage;	// Used only if opaque
-    Pixmap pixmap;	// Used only if not opaque
-    Pixmap mask;	// Used only if not opaque
+    int width;
+    int height;
+    XImage *ximage;		// Used only if opaque
+    Pixmap pixmap;		// Used only if not opaque
+    Pixmap mask;		// Used only if not opaque
 };
 
 
 /*
  *	Sticker::Sticker - create an empty Sticker
  */
-Sticker::Sticker ()
+Sticker::Sticker()
 {
-  priv = new Sticker_priv ();
+    priv = new Sticker_priv();
 }
 
 
 /*
  *	Sticker::Sticker - create a Sticker from an Img
  */
-Sticker::Sticker (const Img& img, bool opaque)
+Sticker::Sticker(const Img & img, bool opaque)
 {
-  priv = new Sticker_priv ();
-  priv->load (img, opaque);
+    priv = new Sticker_priv();
+    priv->load(img, opaque);
 }
 
 
 /*
  *	Sticker::~Sticker - destroy a Sticker
  */
-Sticker::~Sticker ()
+Sticker::~Sticker()
 {
-  delete priv;
-} 
+    delete priv;
+}
 
 
 /*
  *	Sticker::is_clear - tells whether a sprite is "empty"
  */
-bool Sticker::is_clear ()
+bool Sticker::is_clear()
 {
-  return ! priv->has_data;
+    return !priv->has_data;
 }
 
 
 /*
  *	Sticker::clear - clear a Sticker
  */
-void Sticker::clear ()
+void Sticker::clear()
 {
-  priv->clear ();
+    priv->clear();
 }
 
 
 /*
  *	Sticker::load - load an Img into a Sticker
  */
-void Sticker::load (const Img& img, bool opaque)
+void Sticker::load(const Img & img, bool opaque)
 {
-  priv->load (img, opaque);
+    priv->load(img, opaque);
 }
 
 
 /*
  *	Sticker::draw - draw a Sticker
  */
-void Sticker::draw (Drawable drw, char grav, int x, int y)
+void Sticker::draw(Drawable drw, char grav, int x, int y)
 {
-  if (! priv->has_data)
-    return;
-  int x0 = grav == 'c' ? x - priv->width  / 2 : x;
-  int y0 = grav == 'c' ? y - priv->height / 2 : y;
-  if (priv->opaque)
-  {
-    XPutImage (dpy, drw, gc, priv->ximage, 0, 0,
-      x0, y0, priv->width, priv->height);
-  }
-  else
-  {
-    XSetClipMask (dpy, gc, priv->mask);
-    XSetClipOrigin (dpy, gc, x0, y0);
-    XCopyArea (dpy, priv->pixmap, drw, gc, 0, 0, priv->width,
-      priv->height, x0, y0);
-    XSetClipMask (dpy, gc, None);
-  }
-}
-
-
-Sticker_priv::Sticker_priv ()
-{
-  has_data = false;
-}
-
-
-Sticker_priv::~Sticker_priv ()
-{
-  clear ();
-}
-
-
-void Sticker_priv::clear ()
-{
-  if (has_data)
-  {
-    if (opaque)
+    if (!priv->has_data)
+	return;
+    int x0 = grav == 'c' ? x - priv->width / 2 : x;
+    int y0 = grav == 'c' ? y - priv->height / 2 : y;
+    if (priv->opaque)
     {
-      XDestroyImage (ximage);  // Also frees buf.
+	XPutImage(dpy, drw, gc, priv->ximage, 0, 0,
+		  x0, y0, priv->width, priv->height);
     }
     else
     {
-      XFreePixmap (dpy, pixmap);
-      XFreePixmap (dpy, mask);
+	XSetClipMask(dpy, gc, priv->mask);
+	XSetClipOrigin(dpy, gc, x0, y0);
+	XCopyArea(dpy, priv->pixmap, drw, gc, 0, 0, priv->width,
+		  priv->height, x0, y0);
+	XSetClipMask(dpy, gc, None);
     }
+}
+
+
+Sticker_priv::Sticker_priv()
+{
     has_data = false;
-  }
+}
+
+
+Sticker_priv::~Sticker_priv()
+{
+    clear();
+}
+
+
+void Sticker_priv::clear()
+{
+    if (has_data)
+    {
+	if (opaque)
+	{
+	    XDestroyImage(ximage);	// Also frees buf.
+	}
+	else
+	{
+	    XFreePixmap(dpy, pixmap);
+	    XFreePixmap(dpy, mask);
+	}
+	has_data = false;
+    }
 }
 
- 
-void Sticker_priv::load (const Img& img, bool opaque)
+
+void Sticker_priv::load(const Img & img, bool opaque)
 {
-  this->opaque = opaque;
-  clear ();
+    this->opaque = opaque;
+    clear();
 
-  width  = img.width ();
-  height = img.height ();
-  if (width < 1 || height < 1)
-    return;  // Can't create Pixmaps with null dimensions...
+    width = img.width();
+    height = img.height();
+    if (width < 1 || height < 1)
+	return;			// Can't create Pixmaps with null dimensions...
 
-  if (opaque)
-  {
-    ximage = make_ximage (img);
-    if (ximage != 0)
-      has_data = true;
-  }
-  else
-  {
-    // Create a pixmap and copy the image onto it.
-    pixmap = XCreatePixmap (dpy, win, width, height, win_depth);
-    XImage *image = make_ximage (img);
-    if (image != 0)
+    if (opaque)
     {
-      XPutImage (dpy, pixmap, gc, image, 0, 0, 0, 0, width, height);
-      XDestroyImage (image);
+	ximage = make_ximage(img);
+	if (ximage != 0)
+	    has_data = true;
     }
-
-    // Create the mask pixmap and copy the silhouette onto it.
-    mask = XCreatePixmap (dpy, win, width, height, 1);
-    XImage *mask_image = make_bitmap (img);
-    if (mask_image != 0)
+    else
     {
-      GC mask_gc = XCreateGC (dpy, mask, 0, 0);
-      XSetBackground (dpy, mask_gc, 0);
-      XSetForeground (dpy, mask_gc, 1);
-      XPutImage (dpy, mask, mask_gc, mask_image, 0, 0, 0, 0, width, height);
-      XFreeGC (dpy, mask_gc);
-      XDestroyImage (mask_image);
+	// Create a pixmap and copy the image onto it.
+	pixmap = XCreatePixmap(dpy, win, width, height, win_depth);
+	XImage *image = make_ximage(img);
+	if (image != 0)
+	{
+	    XPutImage(dpy, pixmap, gc, image, 0, 0, 0, 0, width, height);
+	    XDestroyImage(image);
+	}
+
+	// Create the mask pixmap and copy the silhouette onto it.
+	mask = XCreatePixmap(dpy, win, width, height, 1);
+	XImage *mask_image = make_bitmap(img);
+	if (mask_image != 0)
+	{
+	    GC mask_gc = XCreateGC(dpy, mask, 0, 0);
+	    XSetBackground(dpy, mask_gc, 0);
+	    XSetForeground(dpy, mask_gc, 1);
+	    XPutImage(dpy, mask, mask_gc, mask_image, 0, 0, 0, 0, width,
+		      height);
+	    XFreeGC(dpy, mask_gc);
+	    XDestroyImage(mask_image);
+	}
+
+	has_data = true;
     }
-
-    has_data = true;
-  }
 }
 
 
@@ -217,198 +217,209 @@
  *	Return pointer to XImage on success, null pointer on
  *	failure.
  */
-XImage *Sticker_priv::make_ximage (const Img& img)
+XImage *Sticker_priv::make_ximage(const Img & img)
 {
-  // How many bytes per line do we need ?
-  size_t bytes_per_line = width * ximage_bpp;
-  if (ximage_quantum == 0)  // Paranoia
-  {
-    nf_bug ("ximage_quantum == 0");
-    ximage_quantum = 1;
-  }
-  size_t padding = 0;
-  while (bytes_per_line % ximage_quantum)
-  {
-    bytes_per_line++;
-    padding++;
-  }
-  u8 *buf = (u8 *) GetMemory ((unsigned long) bytes_per_line * height);
-  if (! buf)
-  {
-    err ("Not enough memory to display %dx%d image", width, height);
-    return 0;
-  }
+    // How many bytes per line do we need ?
+    size_t bytes_per_line = width * ximage_bpp;
+    if (ximage_quantum == 0)	// Paranoia
+    {
+	nf_bug("ximage_quantum == 0");
+	ximage_quantum = 1;
+    }
+    size_t padding = 0;
+    while (bytes_per_line % ximage_quantum)
+    {
+	bytes_per_line++;
+	padding++;
+    }
+    u8 *buf = (u8 *) GetMemory((unsigned long) bytes_per_line * height);
+    if (!buf)
+    {
+	err("Not enough memory to display %dx%d image", width, height);
+	return 0;
+    }
+
+    // Copy the Img onto the XImage.
+    const img_pixel_t *image_end = img.buf() + width * height;
+    if (ximage_bpp == 1)
+    {
+	register const img_pixel_t *image_ptr;
+	register u8 *buf_ptr = (u8 *) buf;
+	if (padding == 0)
+	{
+	    for (image_ptr = img.buf(); image_ptr < image_end; image_ptr++)
+		*buf_ptr++ = (u8) game_colour[*image_ptr];
+	}
+	else
+	{
+	    const img_pixel_t *image_line_end;
+	    int img_width = width;
+	    for (image_ptr = image_line_end = img.buf();
+		 image_ptr < image_end;)
+	    {
+		image_line_end += img_width;
+		for (; image_ptr < image_line_end; image_ptr++)
+		    *buf_ptr++ = (u8) game_colour[*image_ptr];
+		buf_ptr += padding;	// Line padding
+	    }
+	}
+    }
 
-  // Copy the Img onto the XImage.
-  const img_pixel_t *image_end = img.buf () + width * height;
-  if (ximage_bpp == 1)
-  {
-    register const img_pixel_t *image_ptr;
-    register u8 *buf_ptr = (u8 *) buf;
-    if (padding == 0)
+    else if (ximage_bpp == 2)
+    {
+	register const img_pixel_t *image_ptr;
+	register u16 *buf_ptr = (u16 *) buf;
+	if (cpu_big_endian == x_server_big_endian)
+	{
+	    if (padding == 0)
+	    {
+		for (image_ptr = img.buf(); image_ptr < image_end;
+		     image_ptr++)
+		    *buf_ptr++ = (u16) game_colour[*image_ptr];
+	    }
+	    else
+	    {
+		const img_pixel_t *image_line_end;
+		int img_width = width;
+		for (image_ptr = image_line_end = img.buf();
+		     image_ptr < image_end;)
+		{
+		    image_line_end += img_width;
+		    for (; image_ptr < image_line_end; image_ptr++)
+			*buf_ptr++ = (u16) game_colour[*image_ptr];
+		    buf_ptr = (u16 *) ((char *) buf_ptr + padding);	// Line padding
+		}
+	    }
+	}
+	else			// Different endiannesses so swap bytes
+	{
+	    if (padding == 0)
+	    {
+		for (image_ptr = img.buf(); image_ptr < image_end;
+		     image_ptr++)
+		    *buf_ptr++ = (u16) ((game_colour[*image_ptr] >> 8)	// Assume game_colour unsigned
+					| (game_colour[*image_ptr] << 8));
+	    }
+	    else
+	    {
+		const img_pixel_t *image_line_end;
+		int img_width = width;
+		for (image_ptr = image_line_end = img.buf();
+		     image_ptr < image_end;)
+		{
+		    image_line_end += img_width;
+		    for (; image_ptr < image_line_end; image_ptr++)
+			*buf_ptr++ = (u16) ((game_colour[*image_ptr] >> 8)	// Assume game_colour uns.
+					    | (game_colour[*image_ptr] << 8));
+		    buf_ptr = (u16 *) ((char *) buf_ptr + padding);	// Line padding
+		}
+	    }
+	}
+    }
+
+    else if (ximage_bpp == 3)
     {
-      for (image_ptr = img.buf (); image_ptr < image_end; image_ptr++)
-	*buf_ptr++ = (u8) game_colour[*image_ptr];
+	const pv24_t *const pixel_value = game_colour_24.lut();
+	register const img_pixel_t *image_ptr;
+	register pv24_t *buf_ptr = (pv24_t *) buf;
+	if (padding == 0)
+	{
+	    for (image_ptr = img.buf(); image_ptr < image_end; image_ptr++)
+		memcpy(buf_ptr++, pixel_value + *image_ptr, sizeof *buf_ptr);
+	}
+	else
+	{
+	    const img_pixel_t *image_line_end;
+	    int img_width = width;
+	    for (image_ptr = image_line_end = img.buf();
+		 image_ptr < image_end;)
+	    {
+		image_line_end += img_width;
+		for (; image_ptr < image_line_end; image_ptr++)
+		    memcpy(buf_ptr++, pixel_value + *image_ptr,
+			   sizeof *buf_ptr);
+		buf_ptr = (pv24_t *) ((char *) buf_ptr + padding);	// Line padding
+	    }
+	}
+    }
+
+    else if (ximage_bpp == 4)
+    {
+	register const img_pixel_t *image_ptr;
+	register u32 *buf_ptr = (u32 *) buf;
+	if (cpu_big_endian == x_server_big_endian)
+	{
+	    if (padding == 0)
+	    {
+		for (image_ptr = img.buf(); image_ptr < image_end;
+		     image_ptr++)
+		    *buf_ptr++ = (u32) game_colour[*image_ptr];
+	    }
+	    else
+	    {
+		const img_pixel_t *image_line_end;
+		int img_width = width;
+		for (image_ptr = image_line_end = img.buf();
+		     image_ptr < image_end;)
+		{
+		    image_line_end += img_width;
+		    for (; image_ptr < image_line_end; image_ptr++)
+			*buf_ptr++ = (u32) game_colour[*image_ptr];
+		    buf_ptr = (u32 *) ((char *) buf_ptr + padding);	// Line padding
+		}
+	    }
+	}
+	else			// Different endiannesses so swap bytes
+	{
+	    if (padding == 0)
+	    {
+		for (image_ptr = img.buf(); image_ptr < image_end;
+		     image_ptr++)
+		    *buf_ptr++ = (u32) ((game_colour[*image_ptr] >> 24)	// Assume game_colour unsigned
+					| (game_colour[*image_ptr] >> 8) &
+					0x0000ff00 | (game_colour[*image_ptr]
+						      << 8) & 0x00ff0000 |
+					(game_colour[*image_ptr] << 24));
+	    }
+	    else
+	    {
+		const img_pixel_t *image_line_end;
+		int img_width = width;
+		for (image_ptr = image_line_end = img.buf();
+		     image_ptr < image_end;)
+		{
+		    image_line_end += img_width;
+		    for (; image_ptr < image_line_end; image_ptr++)
+			*buf_ptr++ = (u32) ((game_colour[*image_ptr] >> 24)	// Assume game_colour uns.
+					    | (game_colour[*image_ptr] >> 8) &
+					    0x0000ff00 |
+					    (game_colour[*image_ptr] << 8) &
+					    0x00ff0000 |
+					    (game_colour[*image_ptr] << 24));
+		    buf_ptr = (u32 *) ((char *) buf_ptr + padding);	// Line padding
+		}
+	    }
+	}
+    }
+
+    XImage *ximage = XCreateImage(dpy, win_vis, win_depth, ZPixmap, 0,
+				  (char *) buf, width, height, 8,
+				  bytes_per_line);
+    if (ximage == 0)
+    {
+	err("XCreateImage() returned NULL");
+	FreeMemory(buf);
     }
     else
     {
-      const img_pixel_t *image_line_end;
-      int img_width = width;
-      for (image_ptr = image_line_end = img.buf (); image_ptr < image_end;)
-      {
-	image_line_end += img_width;
-	for (; image_ptr < image_line_end; image_ptr++)
-	  *buf_ptr++ = (u8) game_colour[*image_ptr];
-	buf_ptr += padding;  // Line padding
-      }
-    }
-  }
-
-  else if (ximage_bpp == 2)
-  {
-    register const img_pixel_t *image_ptr;
-    register u16 *buf_ptr = (u16 *) buf;
-    if (cpu_big_endian == x_server_big_endian)
-    {
-      if (padding == 0)
-      {
-	for (image_ptr = img.buf (); image_ptr < image_end; image_ptr++)
-	  *buf_ptr++ = (u16) game_colour[*image_ptr];
-      }
-      else
-      {
-	const img_pixel_t *image_line_end;
-	int img_width = width;
-	for (image_ptr = image_line_end = img.buf (); image_ptr < image_end;)
-	{
-	  image_line_end += img_width;
-	  for (; image_ptr < image_line_end; image_ptr++)
-	    *buf_ptr++ = (u16) game_colour[*image_ptr];
-	  buf_ptr = (u16 *) ((char *) buf_ptr + padding);  // Line padding
-	}
-      }
-    }
-    else  // Different endiannesses so swap bytes
-    {
-      if (padding == 0)
-      {
-	for (image_ptr = img.buf (); image_ptr < image_end; image_ptr++)
-	   *buf_ptr++ = (u16) (
-		 (game_colour[*image_ptr] >> 8)  // Assume game_colour unsigned
-	       | (game_colour[*image_ptr] << 8));
-      }
-      else
-      {
-	const img_pixel_t *image_line_end;
-	int img_width = width;
-	for (image_ptr = image_line_end = img.buf (); image_ptr < image_end;)
-	{
-	  image_line_end += img_width;
-	  for (; image_ptr < image_line_end; image_ptr++)
-	     *buf_ptr++ = (u16) (
-		   (game_colour[*image_ptr] >> 8)  // Assume game_colour uns.
-		 | (game_colour[*image_ptr] << 8));
-	  buf_ptr = (u16 *) ((char *) buf_ptr + padding);  // Line padding
-	}
-      }
-    }
-  }
-
-  else if (ximage_bpp == 3)
-  {
-    const pv24_t *const pixel_value = game_colour_24.lut ();
-    register const img_pixel_t *image_ptr;
-    register pv24_t *buf_ptr = (pv24_t *) buf;
-    if (padding == 0)
-    {
-      for (image_ptr = img.buf (); image_ptr < image_end; image_ptr++)
-	memcpy (buf_ptr++, pixel_value + *image_ptr, sizeof *buf_ptr);
+	if (ximage->byte_order == LSBFirst && !x_server_big_endian
+	    || ximage->byte_order == MSBFirst && x_server_big_endian)
+	    ;			// OK
+	else
+	    warn("image byte_order %d doesn't match X server endianness\n",
+		 ximage->byte_order);
     }
-    else
-    {
-      const img_pixel_t *image_line_end;
-      int img_width = width;
-      for (image_ptr = image_line_end = img.buf (); image_ptr < image_end;)
-      {
-	image_line_end += img_width;
-	for (; image_ptr < image_line_end; image_ptr++)
-	  memcpy (buf_ptr++, pixel_value + *image_ptr, sizeof *buf_ptr);
-	buf_ptr = (pv24_t *) ((char *) buf_ptr + padding);  // Line padding
-      }
-    }
-  }
-
-  else if (ximage_bpp == 4)
-  {
-    register const img_pixel_t *image_ptr;
-    register u32 *buf_ptr = (u32 *) buf;
-    if (cpu_big_endian == x_server_big_endian)
-    {
-      if (padding == 0)
-      {
-	for (image_ptr = img.buf (); image_ptr < image_end; image_ptr++)
-	  *buf_ptr++ = (u32) game_colour[*image_ptr];
-      }
-      else
-      {
-	const img_pixel_t *image_line_end;
-	int img_width = width;
-	for (image_ptr = image_line_end = img.buf (); image_ptr < image_end;)
-	{
-	  image_line_end += img_width;
-	  for (; image_ptr < image_line_end; image_ptr++)
-	    *buf_ptr++ = (u32) game_colour[*image_ptr];
-	  buf_ptr = (u32 *) ((char *) buf_ptr + padding);  // Line padding
-	}
-      }
-    }
-    else  // Different endiannesses so swap bytes
-    {
-      if (padding == 0)
-      {
-	for (image_ptr = img.buf (); image_ptr < image_end; image_ptr++)
-	  *buf_ptr++ = (u32) (
-	      (game_colour[*image_ptr] >> 24)  // Assume game_colour unsigned
-	    | (game_colour[*image_ptr] >> 8) & 0x0000ff00
-	    | (game_colour[*image_ptr] << 8) & 0x00ff0000
-	    | (game_colour[*image_ptr] << 24));
-      }
-      else
-      {
-	const img_pixel_t *image_line_end;
-	int img_width = width;
-	for (image_ptr = image_line_end = img.buf (); image_ptr < image_end;)
-	{
-	  image_line_end += img_width;
-	  for (; image_ptr < image_line_end; image_ptr++)
-	    *buf_ptr++ = (u32) (
-		(game_colour[*image_ptr] >> 24)  // Assume game_colour uns.
-	      | (game_colour[*image_ptr] >> 8) & 0x0000ff00
-	      | (game_colour[*image_ptr] << 8) & 0x00ff0000
-	      | (game_colour[*image_ptr] << 24));
-	  buf_ptr = (u32 *) ((char *) buf_ptr + padding);  // Line padding
-	}
-      }
-    }
-  }
-
-  XImage *ximage = XCreateImage (dpy, win_vis, win_depth, ZPixmap, 0,
-    (char *) buf, width, height, 8, bytes_per_line);
-  if (ximage == 0)
-  {
-    err ("XCreateImage() returned NULL");
-    FreeMemory (buf);
-  }
-  else
-  {
-    if (ximage->byte_order == LSBFirst && ! x_server_big_endian
-     || ximage->byte_order == MSBFirst && x_server_big_endian)
-      ;  // OK
-    else
-      warn ("image byte_order %d doesn't match X server endianness\n",
-	  ximage->byte_order);
-  }
-  return ximage;
+    return ximage;
 }
 
 
@@ -418,113 +429,174 @@
  *	Return pointer on XImage on success, null pointer on
  *	failure.
  */
-XImage *Sticker_priv::make_bitmap (const Img& img)
+XImage *Sticker_priv::make_bitmap(const Img & img)
 {
-  int width  = img.width ();
-  int height = img.height ();
-
-  // How many bytes per line do we need ?
-  if (CHAR_BIT != 8)  // Pure paranoia
-  {
-    nf_bug ("Panic: CHAR_BIT != 8 (%d)", (int) CHAR_BIT);
-    return 0;
-  }
-  const size_t bitmap_pad     = BitmapPad (dpy);
-  const size_t bytes_per_line = (width + bitmap_pad - 1) / bitmap_pad
-				* bitmap_pad / CHAR_BIT;
-  u8 *buf = (u8 *) GetMemory ((unsigned long) bytes_per_line * height);
-  if (! buf)
-  {
-    err ("Not enough memory to display %dx%d image", width, height);
-    return 0;
-  }
+    int width = img.width();
+    int height = img.height();
 
-  // Copy the "profile" of the Img onto the XImage
-  {
-    int bitmap_bit_order = BitmapBitOrder (dpy);
-    register u8 *buf_ptr = (u8 *) buf;
-    const int IMG_TRANSP = 0;
-    const img_pixel_t       *image_ptr = img.buf ();
-    const img_pixel_t *const image_end = image_ptr + width * height;
-
-    while (image_ptr < image_end)
+    // How many bytes per line do we need ?
+    if (CHAR_BIT != 8)		// Pure paranoia
+    {
+	nf_bug("Panic: CHAR_BIT != 8 (%d)", (int) CHAR_BIT);
+	return 0;
+    }
+    const size_t bitmap_pad = BitmapPad(dpy);
+    const size_t bytes_per_line = (width + bitmap_pad - 1) / bitmap_pad
+	* bitmap_pad / CHAR_BIT;
+    u8 *buf = (u8 *) GetMemory((unsigned long) bytes_per_line * height);
+    if (!buf)
     {
-      register const u8 *src   = image_ptr;
-      const u8 *const    stop1 = src + width - 7;
-      const u8 *const    stop2 = image_ptr + width;
-      u8* dest = buf_ptr;
-      if (bitmap_bit_order == LSBFirst)
-      {
-	while (src < stop1)
-	{
-	  register u8 d = 0;
-	  if (*src++ != IMG_TRANSP) d |= 1;
-	  if (*src++ != IMG_TRANSP) d |= 2;
-	  if (*src++ != IMG_TRANSP) d |= 4;
-	  if (*src++ != IMG_TRANSP) d |= 8;
-	  if (*src++ != IMG_TRANSP) d |= 16;
-	  if (*src++ != IMG_TRANSP) d |= 32;
-	  if (*src++ != IMG_TRANSP) d |= 64;
-	  if (*src++ != IMG_TRANSP) d |= 128;
-	  *dest++ = d;
-	}
-	if (src < stop2)
+	err("Not enough memory to display %dx%d image", width, height);
+	return 0;
+    }
+
+    // Copy the "profile" of the Img onto the XImage
+    {
+	int bitmap_bit_order = BitmapBitOrder(dpy);
+	register u8 *buf_ptr = (u8 *) buf;
+	const int IMG_TRANSP = 0;
+	const img_pixel_t *image_ptr = img.buf();
+	const img_pixel_t *const image_end = image_ptr + width * height;
+
+	while (image_ptr < image_end)
 	{
-	  register u8 d = 0;
-	  if (*src++ != IMG_TRANSP) d |= 1;   if (src >= stop2) goto eol_le;
-	  if (*src++ != IMG_TRANSP) d |= 2;   if (src >= stop2) goto eol_le;
-	  if (*src++ != IMG_TRANSP) d |= 4;   if (src >= stop2) goto eol_le;
-	  if (*src++ != IMG_TRANSP) d |= 8;   if (src >= stop2) goto eol_le;
-	  if (*src++ != IMG_TRANSP) d |= 16;  if (src >= stop2) goto eol_le;
-	  if (*src++ != IMG_TRANSP) d |= 32;  if (src >= stop2) goto eol_le;
-	  if (*src++ != IMG_TRANSP) d |= 64;  if (src >= stop2) goto eol_le;
-	  if (*src++ != IMG_TRANSP) d |= 128;
-	  eol_le:
-	  *dest = d;
-	}
-      }
-      else if (bitmap_bit_order == MSBFirst)
-      {
-	while (src < stop1)
-	{
-	  register u8 d = 0;
-	  if (*src++ != IMG_TRANSP) d |= 128;
-	  if (*src++ != IMG_TRANSP) d |= 64;
-	  if (*src++ != IMG_TRANSP) d |= 32;
-	  if (*src++ != IMG_TRANSP) d |= 16;
-	  if (*src++ != IMG_TRANSP) d |= 8;
-	  if (*src++ != IMG_TRANSP) d |= 4;
-	  if (*src++ != IMG_TRANSP) d |= 2;
-	  if (*src++ != IMG_TRANSP) d |= 1;
-	  *dest++ = d;
+	    register const u8 *src = image_ptr;
+	    const u8 *const stop1 = src + width - 7;
+	    const u8 *const stop2 = image_ptr + width;
+	    u8 *dest = buf_ptr;
+	    if (bitmap_bit_order == LSBFirst)
+	    {
+		while (src < stop1)
+		{
+		    register u8 d = 0;
+		    if (*src++ != IMG_TRANSP)
+			d |= 1;
+		    if (*src++ != IMG_TRANSP)
+			d |= 2;
+		    if (*src++ != IMG_TRANSP)
+			d |= 4;
+		    if (*src++ != IMG_TRANSP)
+			d |= 8;
+		    if (*src++ != IMG_TRANSP)
+			d |= 16;
+		    if (*src++ != IMG_TRANSP)
+			d |= 32;
+		    if (*src++ != IMG_TRANSP)
+			d |= 64;
+		    if (*src++ != IMG_TRANSP)
+			d |= 128;
+		    *dest++ = d;
+		}
+		if (src < stop2)
+		{
+		    register u8 d = 0;
+		    if (*src++ != IMG_TRANSP)
+			d |= 1;
+		    if (src >= stop2)
+			goto eol_le;
+		    if (*src++ != IMG_TRANSP)
+			d |= 2;
+		    if (src >= stop2)
+			goto eol_le;
+		    if (*src++ != IMG_TRANSP)
+			d |= 4;
+		    if (src >= stop2)
+			goto eol_le;
+		    if (*src++ != IMG_TRANSP)
+			d |= 8;
+		    if (src >= stop2)
+			goto eol_le;
+		    if (*src++ != IMG_TRANSP)
+			d |= 16;
+		    if (src >= stop2)
+			goto eol_le;
+		    if (*src++ != IMG_TRANSP)
+			d |= 32;
+		    if (src >= stop2)
+			goto eol_le;
+		    if (*src++ != IMG_TRANSP)
+			d |= 64;
+		    if (src >= stop2)
+			goto eol_le;
+		    if (*src++ != IMG_TRANSP)
+			d |= 128;
+		  eol_le:
+		    *dest = d;
+		}
+	    }
+	    else if (bitmap_bit_order == MSBFirst)
+	    {
+		while (src < stop1)
+		{
+		    register u8 d = 0;
+		    if (*src++ != IMG_TRANSP)
+			d |= 128;
+		    if (*src++ != IMG_TRANSP)
+			d |= 64;
+		    if (*src++ != IMG_TRANSP)
+			d |= 32;
+		    if (*src++ != IMG_TRANSP)
+			d |= 16;
+		    if (*src++ != IMG_TRANSP)
+			d |= 8;
+		    if (*src++ != IMG_TRANSP)
+			d |= 4;
+		    if (*src++ != IMG_TRANSP)
+			d |= 2;
+		    if (*src++ != IMG_TRANSP)
+			d |= 1;
+		    *dest++ = d;
+		}
+		if (src < stop2)
+		{
+		    register u8 d = 0;
+		    if (*src++ != IMG_TRANSP)
+			d |= 128;
+		    if (src >= stop2)
+			goto eol_be;
+		    if (*src++ != IMG_TRANSP)
+			d |= 64;
+		    if (src >= stop2)
+			goto eol_be;
+		    if (*src++ != IMG_TRANSP)
+			d |= 32;
+		    if (src >= stop2)
+			goto eol_be;
+		    if (*src++ != IMG_TRANSP)
+			d |= 16;
+		    if (src >= stop2)
+			goto eol_be;
+		    if (*src++ != IMG_TRANSP)
+			d |= 8;
+		    if (src >= stop2)
+			goto eol_be;
+		    if (*src++ != IMG_TRANSP)
+			d |= 4;
+		    if (src >= stop2)
+			goto eol_be;
+		    if (*src++ != IMG_TRANSP)
+			d |= 2;
+		    if (src >= stop2)
+			goto eol_be;
+		    if (*src++ != IMG_TRANSP)
+			d |= 1;
+		  eol_be:
+		    *dest = d;
+		}
+	    }
+	    buf_ptr += bytes_per_line;
+	    image_ptr += width;
 	}
-	if (src < stop2)
-	{
-	  register u8 d = 0;
-	  if (*src++ != IMG_TRANSP) d |= 128; if (src >= stop2) goto eol_be;
-	  if (*src++ != IMG_TRANSP) d |= 64;  if (src >= stop2) goto eol_be;
-	  if (*src++ != IMG_TRANSP) d |= 32;  if (src >= stop2) goto eol_be;
-	  if (*src++ != IMG_TRANSP) d |= 16;  if (src >= stop2) goto eol_be;
-	  if (*src++ != IMG_TRANSP) d |= 8;   if (src >= stop2) goto eol_be;
-	  if (*src++ != IMG_TRANSP) d |= 4;   if (src >= stop2) goto eol_be;
-	  if (*src++ != IMG_TRANSP) d |= 2;   if (src >= stop2) goto eol_be;
-	  if (*src++ != IMG_TRANSP) d |= 1;
-	  eol_be:
-	  *dest = d;
-	}
-      }
-      buf_ptr += bytes_per_line;
-      image_ptr += width;
     }
-  }
 
-  XImage *ximage = XCreateImage (dpy, win_vis, 1, XYBitmap, 0,
-    (char *) buf, width, height, bitmap_pad, bytes_per_line);
-  if (ximage == 0)
-  {
-    err ("XCreateImage() returned NULL");
-    FreeMemory (buf);
-    return 0;
-  }
-  return ximage;
+    XImage *ximage = XCreateImage(dpy, win_vis, 1, XYBitmap, 0,
+				  (char *) buf, width, height, bitmap_pad,
+				  bytes_per_line);
+    if (ximage == 0)
+    {
+	err("XCreateImage() returned NULL");
+	FreeMemory(buf);
+	return 0;
+    }
+    return ximage;
 }
--- a/src/sticker.h	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/sticker.h	Sat Sep 24 14:16:04 2011 +0300
@@ -10,18 +10,15 @@
 
 class Sticker
 {
-  public :
-    Sticker ();
-    Sticker (const Img& img, bool opaque);
-    ~Sticker ();
-    bool is_clear ();
-    void clear ();
-    void load (const Img& img, bool opaque);
-    void draw (Drawable drw, char grav, int x, int y);
+    public: Sticker();
+    Sticker(const Img & img, bool opaque);
+     ~Sticker();
+    bool is_clear();
+    void clear();
+    void load(const Img & img, bool opaque);
+    void draw(Drawable drw, char grav, int x, int y);
 
-  private :
-    Sticker (const Sticker&);			// Too lazy to implement it
-    Sticker& operator= (const Sticker&);	// Too lazy to implement it
+      private:Sticker(const Sticker &);	// Too lazy to implement it
+      Sticker & operator=(const Sticker &);	// Too lazy to implement it
     Sticker_priv *priv;
 };
-
--- a/src/t_centre.cc	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/t_centre.cc	Sat Sep 24 14:16:04 2011 +0300
@@ -38,30 +38,28 @@
  *	centre_of_things
  *	Return the coordinates of the centre of a group of things.
  */
-void centre_of_things (SelPtr list, int *x, int *y)
+void centre_of_things(SelPtr list, int *x, int *y)
 {
-SelPtr cur;
-int nitems;
-long x_sum;
-long y_sum;
+    SelPtr cur;
+    int nitems;
+    long x_sum;
+    long y_sum;
 
-x_sum = 0;
-y_sum = 0;
-for (nitems = 0, cur = list; cur; cur = cur->next, nitems++)
-   {
-   x_sum += Things[cur->objnum].xpos;
-   y_sum += Things[cur->objnum].ypos;
-   }
-if (nitems == 0)
-   {
-   *x = 0;
-   *y = 0;
-   }
-else
-   {
-   *x = (int) (x_sum / nitems);
-   *y = (int) (y_sum / nitems);
-   }
+    x_sum = 0;
+    y_sum = 0;
+    for (nitems = 0, cur = list; cur; cur = cur->next, nitems++)
+    {
+	x_sum += Things[cur->objnum].xpos;
+	y_sum += Things[cur->objnum].ypos;
+    }
+    if (nitems == 0)
+    {
+	*x = 0;
+	*y = 0;
+    }
+    else
+    {
+	*x = (int) (x_sum / nitems);
+	*y = (int) (y_sum / nitems);
+    }
 }
-
-
--- a/src/t_centre.h	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/t_centre.h	Sat Sep 24 14:16:04 2011 +0300
@@ -4,6 +4,4 @@
  */
 
 
-void centre_of_things (SelPtr list, int *x, int *y);
-
-
+void centre_of_things(SelPtr list, int *x, int *y);
--- a/src/t_flags.cc	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/t_flags.cc	Sat Sep 24 14:16:04 2011 +0300
@@ -39,31 +39,29 @@
  *	For all the things in <list>, apply the operator <op>
  *	with the operand <operand> on the flags field.
  */
-void frob_things_flags (SelPtr list, int op, int operand)
+void frob_things_flags(SelPtr list, int op, int operand)
 {
-  SelPtr cur;
-  i16 mask;
+    SelPtr cur;
+    i16 mask;
 
-  if (op == YO_CLEAR || op == YO_SET || op == YO_TOGGLE)
-    mask = 1 << operand;
-  else
-    mask = operand;
+    if (op == YO_CLEAR || op == YO_SET || op == YO_TOGGLE)
+	mask = 1 << operand;
+    else
+	mask = operand;
 
-  for (cur = list; cur; cur = cur->next)
-  {
-    if (op == YO_CLEAR)
-      Things[cur->objnum].when &= ~mask;
-    else if (op == YO_SET)
-      Things[cur->objnum].when |= mask;
-    else if (op == YO_TOGGLE)
-      Things[cur->objnum].when ^= mask;
-    else
+    for (cur = list; cur; cur = cur->next)
     {
-      nf_bug ("frob_things_flags: op=%02X", op);
-      return;
+	if (op == YO_CLEAR)
+	    Things[cur->objnum].when &= ~mask;
+	else if (op == YO_SET)
+	    Things[cur->objnum].when |= mask;
+	else if (op == YO_TOGGLE)
+	    Things[cur->objnum].when ^= mask;
+	else
+	{
+	    nf_bug("frob_things_flags: op=%02X", op);
+	    return;
+	}
     }
-  }
-  MadeChanges = 1;
+    MadeChanges = 1;
 }
-
-
--- a/src/t_flags.h	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/t_flags.h	Sat Sep 24 14:16:04 2011 +0300
@@ -4,5 +4,4 @@
  */
 
 
-void frob_things_flags (SelPtr list, int op, int operand);
-
+void frob_things_flags(SelPtr list, int op, int operand);
--- a/src/t_prop.cc	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/t_prop.cc	Sat Sep 24 14:16:04 2011 +0300
@@ -45,9 +45,9 @@
 /*
  *	Private functions prototypes
  */
-int InputThingType (int x0, int y0, int *number);
-static const char *PrintThinggroup (void *ptr);
-static const char *PrintThingdef (void *ptr);
+int InputThingType(int x0, int y0, int *number);
+static const char *PrintThinggroup(void *ptr);
+static const char *PrintThingdef(void *ptr);
 
 
 /*
@@ -55,132 +55,128 @@
  *	Thing properties dialog. Called by EditObjectsInfo. Was part of
  *	EditObjectsInfo in editobj.c
  */
-void ThingProperties (int x0, int y0, SelPtr obj)
+void ThingProperties(int x0, int y0, SelPtr obj)
 {
-char  *menustr[30];
-int    n, val;
-SelPtr cur;
-int    subwin_y0;
+    char *menustr[30];
+    int n, val;
+    SelPtr cur;
+    int subwin_y0;
 
-for (n = 0; n < 6; n++)
-   menustr[n] = (char *) GetMemory (60);
-sprintf (menustr[5], "Edit thing #%d", obj->objnum);
-sprintf (menustr[0], "Change type          (Current: %s)",
-         get_thing_name (Things[obj->objnum].type));
-sprintf (menustr[1], "Change angle         (Current: %s)",
-         GetAngleName (Things[obj->objnum].angle));
-sprintf (menustr[2], "Change flags         (Current: %s)",
-         GetWhenName (Things[obj->objnum].when));
-sprintf (menustr[3], "Change X position    (Current: %d)",
-         Things[obj->objnum].xpos);
-sprintf (menustr[4], "Change Y position    (Current: %d)",
-         Things[obj->objnum].ypos);
-val = vDisplayMenu (x0, y0, menustr[5],
-   menustr[0], YK_, 0,
-   menustr[1], YK_, 0,
-   menustr[2], YK_, 0,
-   menustr[3], YK_, 0,
-   menustr[4], YK_, 0,
-   NULL);
-for (n = 0; n < 6; n++)
-   FreeMemory (menustr[n]);
-subwin_y0 = y0 + BOX_BORDER + (2 + val) * FONTH;
-switch (val)
-  {
-  case 1:
-     if (! InputThingType (x0, subwin_y0, &val))
+    for (n = 0; n < 6; n++)
+	menustr[n] = (char *) GetMemory(60);
+    sprintf(menustr[5], "Edit thing #%d", obj->objnum);
+    sprintf(menustr[0], "Change type          (Current: %s)",
+	    get_thing_name(Things[obj->objnum].type));
+    sprintf(menustr[1], "Change angle         (Current: %s)",
+	    GetAngleName(Things[obj->objnum].angle));
+    sprintf(menustr[2], "Change flags         (Current: %s)",
+	    GetWhenName(Things[obj->objnum].when));
+    sprintf(menustr[3], "Change X position    (Current: %d)",
+	    Things[obj->objnum].xpos);
+    sprintf(menustr[4], "Change Y position    (Current: %d)",
+	    Things[obj->objnum].ypos);
+    val = vDisplayMenu(x0, y0, menustr[5],
+		       menustr[0], YK_, 0,
+		       menustr[1], YK_, 0,
+		       menustr[2], YK_, 0,
+		       menustr[3], YK_, 0, menustr[4], YK_, 0, NULL);
+    for (n = 0; n < 6; n++)
+	FreeMemory(menustr[n]);
+    subwin_y0 = y0 + BOX_BORDER + (2 + val) * FONTH;
+    switch (val)
+    {
+    case 1:
+	if (!InputThingType(x0, subwin_y0, &val))
 	{
-	for (cur = obj; cur; cur = cur->next)
-	   Things[cur->objnum].type = val;
-	things_types++;
-	MadeChanges = 1;
+	    for (cur = obj; cur; cur = cur->next)
+		Things[cur->objnum].type = val;
+	    things_types++;
+	    MadeChanges = 1;
 	}
-     break;
+	break;
 
-  case 2:
-     switch (vDisplayMenu (x0 + 42, subwin_y0, "Select angle",
-			  "North",	YK_, 0,
-			  "NorthEast",	YK_, 0,
-			  "East",	YK_, 0,
-			  "SouthEast",	YK_, 0,
-			  "South",	YK_, 0,
-			  "SouthWest",	YK_, 0,
-			  "West",	YK_, 0,
-			  "NorthWest",	YK_, 0,
-			  NULL))
+    case 2:
+	switch (vDisplayMenu(x0 + 42, subwin_y0, "Select angle",
+			     "North", YK_, 0,
+			     "NorthEast", YK_, 0,
+			     "East", YK_, 0,
+			     "SouthEast", YK_, 0,
+			     "South", YK_, 0,
+			     "SouthWest", YK_, 0,
+			     "West", YK_, 0, "NorthWest", YK_, 0, NULL))
 	{
 	case 1:
-	   for (cur = obj; cur; cur = cur->next)
-	      Things[cur->objnum].angle = 90;
-	   things_angles++;
-	   MadeChanges = 1;
-	   break;
+	    for (cur = obj; cur; cur = cur->next)
+		Things[cur->objnum].angle = 90;
+	    things_angles++;
+	    MadeChanges = 1;
+	    break;
 
 	case 2:
-	   for (cur = obj; cur; cur = cur->next)
-	      Things[cur->objnum].angle = 45;
-	   things_angles++;
-	   MadeChanges = 1;
-	   break;
+	    for (cur = obj; cur; cur = cur->next)
+		Things[cur->objnum].angle = 45;
+	    things_angles++;
+	    MadeChanges = 1;
+	    break;
 
 	case 3:
-	   for (cur = obj; cur; cur = cur->next)
-	      Things[cur->objnum].angle = 0;
-	   things_angles++;
-	   MadeChanges = 1;
-	   break;
+	    for (cur = obj; cur; cur = cur->next)
+		Things[cur->objnum].angle = 0;
+	    things_angles++;
+	    MadeChanges = 1;
+	    break;
 
 	case 4:
-	   for (cur = obj; cur; cur = cur->next)
-	      Things[cur->objnum].angle = 315;
-	   things_angles++;
-	   MadeChanges = 1;
-	   break;
+	    for (cur = obj; cur; cur = cur->next)
+		Things[cur->objnum].angle = 315;
+	    things_angles++;
+	    MadeChanges = 1;
+	    break;
 
 	case 5:
-	   for (cur = obj; cur; cur = cur->next)
-	      Things[cur->objnum].angle = 270;
-	   things_angles++;
-	   MadeChanges = 1;
-	   break;
+	    for (cur = obj; cur; cur = cur->next)
+		Things[cur->objnum].angle = 270;
+	    things_angles++;
+	    MadeChanges = 1;
+	    break;
 
 	case 6:
-	   for (cur = obj; cur; cur = cur->next)
-	      Things[cur->objnum].angle = 225;
-	   things_angles++;
-	   MadeChanges = 1;
-	   break;
+	    for (cur = obj; cur; cur = cur->next)
+		Things[cur->objnum].angle = 225;
+	    things_angles++;
+	    MadeChanges = 1;
+	    break;
 
 	case 7:
-	   for (cur = obj; cur; cur = cur->next)
-	      Things[cur->objnum].angle = 180;
-	   things_angles++;
-	   MadeChanges = 1;
-	   break;
+	    for (cur = obj; cur; cur = cur->next)
+		Things[cur->objnum].angle = 180;
+	    things_angles++;
+	    MadeChanges = 1;
+	    break;
 
 	case 8:
-	   for (cur = obj; cur; cur = cur->next)
-	      Things[cur->objnum].angle = 135;
-	   things_angles++;
-	   MadeChanges = 1;
-	   break;
+	    for (cur = obj; cur; cur = cur->next)
+		Things[cur->objnum].angle = 135;
+	    things_angles++;
+	    MadeChanges = 1;
+	    break;
 	}
-     break;
+	break;
 
-  case 3:
-     val = vDisplayMenu (x0 + 42, subwin_y0, "Choose the difficulty level(s)",
-			"D12          (Easy only)",		YK_, 0,
-			"D3           (Medium only)",		YK_, 0,
-			"D12, D3      (Easy and Medium)",	YK_, 0,
-			"D45          (Hard only)",		YK_, 0,
-			"D12, D45     (Easy and Hard)",		YK_, 0,
-			"D3, D45      (Medium and Hard)",	YK_, 0,
-			"D12, D3, D45 (Easy, Medium, Hard)",	YK_, 0,
-			"Toggle \"Deaf/Ambush\" bit",		YK_, 0,
-			"Toggle \"Multi-player only\" bit",	YK_, 0,
-			"(Enter number)",			YK_, 0,
-			NULL);
-     switch (val)
+    case 3:
+	val =
+	    vDisplayMenu(x0 + 42, subwin_y0, "Choose the difficulty level(s)",
+			 "D12          (Easy only)", YK_, 0,
+			 "D3           (Medium only)", YK_, 0,
+			 "D12, D3      (Easy and Medium)", YK_, 0,
+			 "D45          (Hard only)", YK_, 0,
+			 "D12, D45     (Easy and Hard)", YK_, 0,
+			 "D3, D45      (Medium and Hard)", YK_, 0,
+			 "D12, D3, D45 (Easy, Medium, Hard)", YK_, 0,
+			 "Toggle \"Deaf/Ambush\" bit", YK_, 0,
+			 "Toggle \"Multi-player only\" bit", YK_, 0,
+			 "(Enter number)", YK_, 0, NULL);
+	switch (val)
 	{
 	case 1:
 	case 2:
@@ -189,61 +185,63 @@
 	case 5:
 	case 6:
 	case 7:
-	   for (cur = obj; cur; cur = cur->next)
-	      Things[cur->objnum].when = (Things[cur->objnum].when & 0x18) | val;
-	   MadeChanges = 1;
-	   break;
+	    for (cur = obj; cur; cur = cur->next)
+		Things[cur->objnum].when =
+		    (Things[cur->objnum].when & 0x18) | val;
+	    MadeChanges = 1;
+	    break;
 
 	case 8:
-	   for (cur = obj; cur; cur = cur->next)
-	      Things[cur->objnum].when ^= 0x08;
-	   MadeChanges = 1;
-	   break;
+	    for (cur = obj; cur; cur = cur->next)
+		Things[cur->objnum].when ^= 0x08;
+	    MadeChanges = 1;
+	    break;
 
 	case 9:
-	   for (cur = obj; cur; cur = cur->next)
-	      Things[cur->objnum].when ^= 0x10;
-	   MadeChanges = 1;
-	   break;
+	    for (cur = obj; cur; cur = cur->next)
+		Things[cur->objnum].when ^= 0x10;
+	    MadeChanges = 1;
+	    break;
 
 	case 10:
-	   val = InputIntegerValue (x0 + 84,
-              subwin_y0 + BOX_BORDER + (3 + val) * FONTH, 0, 65535,
-	      Things[obj->objnum].when);
-	   if (val != IIV_CANCEL)
-	      {
-	      for (cur = obj; cur; cur = cur->next)
-		 Things[cur->objnum].when = val;
-	      MadeChanges = 1;
-	      }
-	   break;
+	    val = InputIntegerValue(x0 + 84,
+				    subwin_y0 + BOX_BORDER + (3 +
+							      val) * FONTH, 0,
+				    65535, Things[obj->objnum].when);
+	    if (val != IIV_CANCEL)
+	    {
+		for (cur = obj; cur; cur = cur->next)
+		    Things[cur->objnum].when = val;
+		MadeChanges = 1;
+	    }
+	    break;
 	}
-     break;
+	break;
 
-  case 4:
-     val = InputIntegerValue (x0 + 42, subwin_y0, MapMinX, MapMaxX,
-                              Things[obj->objnum].xpos);
-     if (val != IIV_CANCEL)
-        {
-	n = val - Things[obj->objnum].xpos;
-	for (cur = obj; cur; cur = cur->next)
-	   Things[cur->objnum].xpos += n;
-	MadeChanges = 1;
-        }
-     break;
+    case 4:
+	val = InputIntegerValue(x0 + 42, subwin_y0, MapMinX, MapMaxX,
+				Things[obj->objnum].xpos);
+	if (val != IIV_CANCEL)
+	{
+	    n = val - Things[obj->objnum].xpos;
+	    for (cur = obj; cur; cur = cur->next)
+		Things[cur->objnum].xpos += n;
+	    MadeChanges = 1;
+	}
+	break;
 
-  case 5:
-     val = InputIntegerValue (x0 + 42, subwin_y0, MapMinY, MapMaxY,
-                              Things[obj->objnum].ypos);
-     if (val != IIV_CANCEL)
-        {
-	n = val - Things[obj->objnum].ypos;
-	for (cur = obj; cur; cur = cur->next)
-	   Things[cur->objnum].ypos += n;
-	MadeChanges = 1;
-        }
-     break;
-  }
+    case 5:
+	val = InputIntegerValue(x0 + 42, subwin_y0, MapMinY, MapMaxY,
+				Things[obj->objnum].ypos);
+	if (val != IIV_CANCEL)
+	{
+	    n = val - Things[obj->objnum].ypos;
+	    for (cur = obj; cur; cur = cur->next)
+		Things[cur->objnum].ypos += n;
+	    MadeChanges = 1;
+	}
+	break;
+    }
 }
 
 
@@ -252,60 +250,64 @@
  *	Let the user select a thing number and return it.
  *	Returns 0 if OK, <>0 if cancelled
  */
-int InputThingType (int x0, int y0, int *number)
+int InputThingType(int x0, int y0, int *number)
 {
-int         r;
-int         tgno = 0;
-char        tg; 
-al_llist_t *list = NULL;
+    int r;
+    int tgno = 0;
+    char tg;
+    al_llist_t *list = NULL;
 
-for (;;)
-   {
-   /* First let user select a thinggroup */
-   if (DisplayMenuList (x0+42, y0, "Select group", thinggroup,
-    PrintThinggroup, &tgno) < 0)
-      return 1;
-   if (al_lseek (thinggroup, tgno, SEEK_SET))
-      fatal_error ("%s ITT1 (%s)", msg_unexpected, al_astrerror (al_aerrno));
-   tg = CUR_THINGGROUP->thinggroup;
+    for (;;)
+    {
+	/* First let user select a thinggroup */
+	if (DisplayMenuList(x0 + 42, y0, "Select group", thinggroup,
+			    PrintThinggroup, &tgno) < 0)
+	    return 1;
+	if (al_lseek(thinggroup, tgno, SEEK_SET))
+	    fatal_error("%s ITT1 (%s)", msg_unexpected,
+			al_astrerror(al_aerrno));
+	tg = CUR_THINGGROUP->thinggroup;
 
-   /* KLUDGE: Special thinggroup THING_FREE means "enter number".
-      Don't look for this thinggroup in the .ygd file : LoadGameDefs()
-      creates it manually. */
-   if (tg == THING_FREE)
-      {
-      /* FIXME should be unsigned! should accept hex. */
-      *number = InputIntegerValue (x0+84, y0 + BOX_BORDER + (3 + tgno) * FONTH,
-	 -32768, 32767, 0);
-      if (*number != IIV_CANCEL)
-	 break;
-      goto again;
-      }
-     
-   /* Then build a list of pointers on all things that have this
-      thinggroup and let user select one. */
-   list = al_lcreate (sizeof (void *));
-   for (al_lrewind (thingdef); ! al_leol (thingdef); al_lstep (thingdef))
-      if (CUR_THINGDEF->thinggroup == tg)
-	 {
-	 void *ptr = CUR_THINGDEF;
-	 al_lwrite (list, &ptr);
-	 }
-   r = DisplayMenuList (x0+84, y0 + BOX_BORDER + (3 + tgno) * FONTH,
-      "Select thing", list, PrintThingdef, NULL);
-   if (r < 0)
-      goto again;
-   if (al_lseek (list, r, SEEK_SET))
-      fatal_error ("%s ITT2 (%s)", msg_unexpected, al_astrerror (al_aerrno));
-   *number = (*((thingdef_t **) al_lptr (list)))->number;
-   al_ldiscard (list);
-   break;
+	/* KLUDGE: Special thinggroup THING_FREE means "enter number".
+	   Don't look for this thinggroup in the .ygd file : LoadGameDefs()
+	   creates it manually. */
+	if (tg == THING_FREE)
+	{
+	    /* FIXME should be unsigned! should accept hex. */
+	    *number =
+		InputIntegerValue(x0 + 84,
+				  y0 + BOX_BORDER + (3 + tgno) * FONTH,
+				  -32768, 32767, 0);
+	    if (*number != IIV_CANCEL)
+		break;
+	    goto again;
+	}
 
-   again :
-   ;
-   /* DrawMap (OBJ_THINGS, 0, 0); FIXME! */
-   }
-return 0;
+	/* Then build a list of pointers on all things that have this
+	   thinggroup and let user select one. */
+	list = al_lcreate(sizeof(void *));
+	for (al_lrewind(thingdef); !al_leol(thingdef); al_lstep(thingdef))
+	    if (CUR_THINGDEF->thinggroup == tg)
+	    {
+		void *ptr = CUR_THINGDEF;
+		al_lwrite(list, &ptr);
+	    }
+	r = DisplayMenuList(x0 + 84, y0 + BOX_BORDER + (3 + tgno) * FONTH,
+			    "Select thing", list, PrintThingdef, NULL);
+	if (r < 0)
+	    goto again;
+	if (al_lseek(list, r, SEEK_SET))
+	    fatal_error("%s ITT2 (%s)", msg_unexpected,
+			al_astrerror(al_aerrno));
+	*number = (*((thingdef_t **) al_lptr(list)))->number;
+	al_ldiscard(list);
+	break;
+
+      again:
+	;
+	/* DrawMap (OBJ_THINGS, 0, 0); FIXME! */
+    }
+    return 0;
 }
 
 
@@ -313,11 +315,11 @@
  *	PrintThinggroup
  *	Used by DisplayMenuList when called by InputThingType
  */
-static const char *PrintThinggroup (void *ptr)
+static const char *PrintThinggroup(void *ptr)
 {
-if (ptr == NULL)
-   return "PrintThinggroup: (null)";
-return ((thinggroup_t *)ptr)->desc;
+    if (ptr == NULL)
+	return "PrintThinggroup: (null)";
+    return ((thinggroup_t *) ptr)->desc;
 }
 
 
@@ -325,11 +327,11 @@
  *	PrintThingdef
  *	Used by DisplayMenuList when called by InputThingType
  */
-static const char *PrintThingdef (void *ptr)
+static const char *PrintThingdef(void *ptr)
 {
-if (ptr == NULL)
-   return "PrintThingdef: (null)";
-return (*((thingdef_t **)ptr))->desc;
+    if (ptr == NULL)
+	return "PrintThingdef: (null)";
+    return (*((thingdef_t **) ptr))->desc;
 }
 
 
@@ -338,24 +340,24 @@
  *
  *   -AJA- 2001-05-27
  */
-void TransferThingProperties (int src_thing, SelPtr things)
+void TransferThingProperties(int src_thing, SelPtr things)
 {
-   SelPtr cur;
+    SelPtr cur;
 
-   for (cur=things; cur; cur=cur->next)
-   {
-      if (! is_obj(cur->objnum))
-         continue;
+    for (cur = things; cur; cur = cur->next)
+    {
+	if (!is_obj(cur->objnum))
+	    continue;
 
-      Things[cur->objnum].angle = Things[src_thing].angle;
-      Things[cur->objnum].type  = Things[src_thing].type;
-      Things[cur->objnum].when  = Things[src_thing].when;
+	Things[cur->objnum].angle = Things[src_thing].angle;
+	Things[cur->objnum].type = Things[src_thing].type;
+	Things[cur->objnum].when = Things[src_thing].when;
 
-      MadeChanges = 1;
+	MadeChanges = 1;
 
-      things_types++;
-      things_angles++;
-   }
+	things_types++;
+	things_angles++;
+    }
 }
 
 
--- a/src/t_spin.cc	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/t_spin.cc	Sat Sep 24 14:16:04 2011 +0300
@@ -36,22 +36,20 @@
 /*
  *	spin_thing - change the angle of things
  */
-void spin_things (SelPtr obj, int degrees)
+void spin_things(SelPtr obj, int degrees)
 {
-  SelPtr cur;
+    SelPtr cur;
 
-  if (! obj)
-    return;
-  for (cur = obj; cur; cur = cur->next)
-  {
-    Things[cur->objnum].angle += degrees;
-    while (Things[cur->objnum].angle >= 360)	// No we can't use %
-      Things[cur->objnum].angle -= 360;
-    while (Things[cur->objnum].angle < 0)	// (negatives...)
-      Things[cur->objnum].angle += 360;
-  }
-  things_angles++;
-  MadeChanges = 1;
+    if (!obj)
+	return;
+    for (cur = obj; cur; cur = cur->next)
+    {
+	Things[cur->objnum].angle += degrees;
+	while (Things[cur->objnum].angle >= 360)	// No we can't use %
+	    Things[cur->objnum].angle -= 360;
+	while (Things[cur->objnum].angle < 0)	// (negatives...)
+	    Things[cur->objnum].angle += 360;
+    }
+    things_angles++;
+    MadeChanges = 1;
 }
-
-
--- a/src/t_spin.h	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/t_spin.h	Sat Sep 24 14:16:04 2011 +0300
@@ -4,6 +4,4 @@
  */
 
 
-void spin_things (SelPtr obj, int degrees);
-
-
+void spin_things(SelPtr obj, int degrees);
--- a/src/textures.cc	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/textures.cc	Sat Sep 24 14:16:04 2011 +0300
@@ -33,7 +33,7 @@
 #include <X11/Xlib.h>
 #endif
 #include "dialog.h"
-#include "game.h"      /* yg_picture_format */
+#include "game.h"		/* yg_picture_format */
 #include "gfx.h"
 #include "lists.h"
 #include "patchdir.h"
@@ -49,509 +49,515 @@
    display a wall texture ("TEXTURE1" or "TEXTURE2" object)
    at coords c->x0, c->y0
 */
-void DisplayWallTexture (hookfunc_comm_t *c)
+void DisplayWallTexture(hookfunc_comm_t * c)
 {
-MDirPtr  dir = 0;	// Main directory pointer to the TEXTURE* entries
-int      n;		// General counter
-i16      width, height;	// Size of the texture
-i16      npatches;	// Number of patches in the textures
-i32      numtex;	// number of texture names in TEXTURE* list
-i32      texofs;	// Offset in the wad file to the texture data
-char     tname[WAD_TEX_NAME + 1];	/* texture name */
-char     picname[WAD_PIC_NAME + 1];	/* wall patch name */
-bool     have_dummy_bytes;
-int      header_size;
-int      item_size;
+    MDirPtr dir = 0;		// Main directory pointer to the TEXTURE* entries
+    int n;			// General counter
+    i16 width, height;		// Size of the texture
+    i16 npatches;		// Number of patches in the textures
+    i32 numtex;			// number of texture names in TEXTURE* list
+    i32 texofs;			// Offset in the wad file to the texture data
+    char tname[WAD_TEX_NAME + 1];	/* texture name */
+    char picname[WAD_PIC_NAME + 1];	/* wall patch name */
+    bool have_dummy_bytes;
+    int header_size;
+    int item_size;
 
 // So that, on failure, the caller clears the display area
-c->disp_x0 = c->x1;
-c->disp_y0 = c->y1;
-c->disp_x1 = c->x0;
-c->disp_y1 = c->y0;
+    c->disp_x0 = c->x1;
+    c->disp_y0 = c->y1;
+    c->disp_x1 = c->x0;
+    c->disp_y1 = c->y0;
 
 // Iwad-dependant details
-if (yg_texture_format == YGTF_NAMELESS)
-   {
-   have_dummy_bytes = true;
-   header_size      = 14;
-   item_size        = 10;
-   }
-else if (yg_texture_format == YGTF_NORMAL)
-   {
-   have_dummy_bytes = true;
-   header_size      = 14;
-   item_size        = 10;
-   }
-else if (yg_texture_format == YGTF_STRIFE11)
-   {
-   have_dummy_bytes = false;
-   header_size      = 10;
-   item_size        = 6;
-   }
-else
-   {
-   nf_bug ("Bad texture format %d.", (int) yg_texture_format);
-   return;
-   }
+    if (yg_texture_format == YGTF_NAMELESS)
+    {
+	have_dummy_bytes = true;
+	header_size = 14;
+	item_size = 10;
+    }
+    else if (yg_texture_format == YGTF_NORMAL)
+    {
+	have_dummy_bytes = true;
+	header_size = 14;
+	item_size = 10;
+    }
+    else if (yg_texture_format == YGTF_STRIFE11)
+    {
+	have_dummy_bytes = false;
+	header_size = 10;
+	item_size = 6;
+    }
+    else
+    {
+	nf_bug("Bad texture format %d.", (int) yg_texture_format);
+	return;
+    }
 
 #ifndef Y_X11
-if (have_key ())
-   return;				// Speedup
+    if (have_key())
+	return;			// Speedup
 #endif
 
 // Offset for texture we want
-texofs = 0;
+    texofs = 0;
 // Doom alpha 0.4 : "TEXTURES", no names
-if (yg_texture_lumps == YGTL_TEXTURES && yg_texture_format == YGTF_NAMELESS)
-   {
-   const char *lump_name = "TEXTURES";
-   dir = FindMasterDir (MasterDir, lump_name);
-   if (dir != NULL)
-      {
-      const Wad_file *wf = dir->wadfile;
-      wf->seek (dir->dir.start);
-      if (wf->error ())
-	 {
-	 warn ("%s: can't seek to lump\n", lump_name);
-	 goto alpha04_done;
-	 }
-      wf->read_i32 (&numtex);
-      if (wf->error ())
-	 {
-	 warn ("%s: error reading texture count\n", lump_name);
-	 goto alpha04_done;
-	 }
-      if (WAD_TEX_NAME < 7) nf_bug ("WAD_TEX_NAME too small");  // Sanity
-      if (! y_strnicmp (c->name, "TEX", 3)
-	    && isdigit (c->name[3])
-	    && isdigit (c->name[4])
-	    && isdigit (c->name[5])
-	    && isdigit (c->name[6])
-	    && c->name[7] == '\0')
-	 {
-	 long num;
-	 if (sscanf (c->name + 3, "%4ld", &num) == 1
-	       && num >= 0 && num < numtex)
+    if (yg_texture_lumps == YGTL_TEXTURES
+	&& yg_texture_format == YGTF_NAMELESS)
+    {
+	const char *lump_name = "TEXTURES";
+	dir = FindMasterDir(MasterDir, lump_name);
+	if (dir != NULL)
+	{
+	    const Wad_file *wf = dir->wadfile;
+	    wf->seek(dir->dir.start);
+	    if (wf->error())
+	    {
+		warn("%s: can't seek to lump\n", lump_name);
+		goto alpha04_done;
+	    }
+	    wf->read_i32(&numtex);
+	    if (wf->error())
 	    {
-	    wf->seek (dir->dir.start + 4 + 4 * num);
-	    if (wf->error ())
-	       {
-	       // FIXME print name of offending texture (or #)
-	       warn ("%s: can't seek to offsets table entry\n", lump_name);
-	       goto alpha04_done;
-	       }
-	    wf->read_i32 (&texofs);
-	    if (wf->error ())
-	       {
-	       warn ("%s: error reading texture offset\n", lump_name);
-	       goto alpha04_done;
-	       }
-	    texofs += dir->dir.start;
+		warn("%s: error reading texture count\n", lump_name);
+		goto alpha04_done;
 	    }
-	 }
-      }
-   alpha04_done:
-   ;
-   }
+	    if (WAD_TEX_NAME < 7)
+		nf_bug("WAD_TEX_NAME too small");	// Sanity
+	    if (!y_strnicmp(c->name, "TEX", 3)
+		&& isdigit(c->name[3])
+		&& isdigit(c->name[4])
+		&& isdigit(c->name[5])
+		&& isdigit(c->name[6]) && c->name[7] == '\0')
+	    {
+		long num;
+		if (sscanf(c->name + 3, "%4ld", &num) == 1
+		    && num >= 0 && num < numtex)
+		{
+		    wf->seek(dir->dir.start + 4 + 4 * num);
+		    if (wf->error())
+		    {
+			// FIXME print name of offending texture (or #)
+			warn("%s: can't seek to offsets table entry\n",
+			     lump_name);
+			goto alpha04_done;
+		    }
+		    wf->read_i32(&texofs);
+		    if (wf->error())
+		    {
+			warn("%s: error reading texture offset\n", lump_name);
+			goto alpha04_done;
+		    }
+		    texofs += dir->dir.start;
+		}
+	    }
+	}
+      alpha04_done:
+	;
+    }
 // Doom alpha 0.5 : only "TEXTURES"
-else if (yg_texture_lumps == YGTL_TEXTURES
-   && (yg_texture_format == YGTF_NORMAL || yg_texture_format == YGTF_STRIFE11))
-   {
-   const char *lump_name = "TEXTURES";
-   dir = FindMasterDir (MasterDir, lump_name);
-   if (dir != NULL)  // (Theoretically, it should always exist)
-      {
-      i32 *offsets = NULL;  // Array of offsets to texture names
-      const Wad_file *wf = dir->wadfile;
+    else if (yg_texture_lumps == YGTL_TEXTURES
+	     && (yg_texture_format == YGTF_NORMAL
+		 || yg_texture_format == YGTF_STRIFE11))
+    {
+	const char *lump_name = "TEXTURES";
+	dir = FindMasterDir(MasterDir, lump_name);
+	if (dir != NULL)	// (Theoretically, it should always exist)
+	{
+	    i32 *offsets = NULL;	// Array of offsets to texture names
+	    const Wad_file *wf = dir->wadfile;
 
-      wf->seek (dir->dir.start);
-      if (wf->error ())
-	 {
-	 warn ("%s: can't seek to lump\n", lump_name);
-	 goto textures_done;
-	 }
-      wf->read_i32 (&numtex);
-      if (wf->error ())
-	 {
-	 warn ("%s: error reading texture count\n", lump_name);
-	 goto textures_done;
-	 }
-      // Read in the offsets for texture1 names and info
-      offsets = (i32 *) GetMemory ((long) numtex * 4);
-      wf->read_i32 (offsets, numtex);
-      if (wf->error ())
-	 {
-	 warn ("%s: error reading offsets table\n", lump_name);
-	 goto textures_done;
-	 }
-      for (long n = 0; n < numtex && !texofs; n++)
-	 {
-	 wf->seek (dir->dir.start + offsets[n]);
-	 if (wf->error ())
+	    wf->seek(dir->dir.start);
+	    if (wf->error())
+	    {
+		warn("%s: can't seek to lump\n", lump_name);
+		goto textures_done;
+	    }
+	    wf->read_i32(&numtex);
+	    if (wf->error())
+	    {
+		warn("%s: error reading texture count\n", lump_name);
+		goto textures_done;
+	    }
+	    // Read in the offsets for texture1 names and info
+	    offsets = (i32 *) GetMemory((long) numtex * 4);
+	    wf->read_i32(offsets, numtex);
+	    if (wf->error())
+	    {
+		warn("%s: error reading offsets table\n", lump_name);
+		goto textures_done;
+	    }
+	    for (long n = 0; n < numtex && !texofs; n++)
 	    {
-	    warn ("%s: error seeking to definition of texture #%ld\n",
-	      lump_name, n);
-	    break;
+		wf->seek(dir->dir.start + offsets[n]);
+		if (wf->error())
+		{
+		    warn("%s: error seeking to definition of texture #%ld\n",
+			 lump_name, n);
+		    break;
+		}
+		wf->read_bytes(&tname, WAD_TEX_NAME);
+		if (wf->error())
+		{
+		    warn("%s: error reading name of texture #%ld\n",
+			 lump_name, n);
+		    break;
+		}
+		if (!y_strnicmp(tname, c->name, WAD_TEX_NAME))
+		    texofs = dir->dir.start + offsets[n];
 	    }
-	 wf->read_bytes (&tname, WAD_TEX_NAME);
-	 if (wf->error ())
-	    {
-	    warn ("%s: error reading name of texture #%ld\n", lump_name, n);
-	    break;
-	    }
-	 if (!y_strnicmp (tname, c->name, WAD_TEX_NAME))
-	    texofs = dir->dir.start + offsets[n];
-	 }
-      textures_done:
-      if (offsets != NULL)
-	 FreeMemory (offsets);
-      }
-   }
+	  textures_done:
+	    if (offsets != NULL)
+		FreeMemory(offsets);
+	}
+    }
 // Other iwads : "TEXTURE1" and "TEXTURE2"
-else if (yg_texture_lumps == YGTL_NORMAL
-   && (yg_texture_format == YGTF_NORMAL || yg_texture_format == YGTF_STRIFE11))
-   {
-   // Is it in TEXTURE1 ?
-   {
-   const char *lump_name = "TEXTURE1";
-   dir = FindMasterDir (MasterDir, lump_name);
-   if (dir != NULL)  // (Theoretically, it should always exist)
-      {
-      const Wad_file *wf = dir->wadfile;
-      i32 *offsets = NULL;  // Array of offsets to texture names
+    else if (yg_texture_lumps == YGTL_NORMAL
+	     && (yg_texture_format == YGTF_NORMAL
+		 || yg_texture_format == YGTF_STRIFE11))
+    {
+	// Is it in TEXTURE1 ?
+	{
+	    const char *lump_name = "TEXTURE1";
+	    dir = FindMasterDir(MasterDir, lump_name);
+	    if (dir != NULL)	// (Theoretically, it should always exist)
+	    {
+		const Wad_file *wf = dir->wadfile;
+		i32 *offsets = NULL;	// Array of offsets to texture names
 
-      wf->seek (dir->dir.start);
-      if (wf->error ())
-	 {
-	 warn ("%s: can't seek to lump\n", lump_name);
-	 goto texture1_done;
-	 }
-      wf->read_i32 (&numtex);
-      if (wf->error ())
-	 {
-	 warn ("%s: error reading texture count\n", lump_name);
-	 goto texture1_done;
-	 }
-      // Read in the offsets for texture1 names and info
-      offsets = (i32 *) GetMemory ((long) numtex * 4);
-      wf->read_i32 (offsets, numtex);
-      if (wf->error ())
-	 {
-	 warn ("%s: error reading offsets table\n", lump_name);
-	 goto texture1_done;
-	 }
-      for (long n = 0; n < numtex && !texofs; n++)
-	 {
-	 wf->seek (dir->dir.start + offsets[n]);
-	 if (wf->error ())
-	    {
-	    warn ("%s: error seeking to definition of texture #%ld\n",
-	      lump_name, n);
-	    break;
-	    }
-	 wf->read_bytes (&tname, WAD_TEX_NAME);
-	 if (wf->error ())
-	    {
-	    warn ("%s: error reading name of texture #%ld\n", lump_name, n);
-	    break;
+		wf->seek(dir->dir.start);
+		if (wf->error())
+		{
+		    warn("%s: can't seek to lump\n", lump_name);
+		    goto texture1_done;
+		}
+		wf->read_i32(&numtex);
+		if (wf->error())
+		{
+		    warn("%s: error reading texture count\n", lump_name);
+		    goto texture1_done;
+		}
+		// Read in the offsets for texture1 names and info
+		offsets = (i32 *) GetMemory((long) numtex * 4);
+		wf->read_i32(offsets, numtex);
+		if (wf->error())
+		{
+		    warn("%s: error reading offsets table\n", lump_name);
+		    goto texture1_done;
+		}
+		for (long n = 0; n < numtex && !texofs; n++)
+		{
+		    wf->seek(dir->dir.start + offsets[n]);
+		    if (wf->error())
+		    {
+			warn("%s: error seeking to definition of texture #%ld\n", lump_name, n);
+			break;
+		    }
+		    wf->read_bytes(&tname, WAD_TEX_NAME);
+		    if (wf->error())
+		    {
+			warn("%s: error reading name of texture #%ld\n",
+			     lump_name, n);
+			break;
+		    }
+		    if (!y_strnicmp(tname, c->name, WAD_TEX_NAME))
+			texofs = dir->dir.start + offsets[n];
+		}
+	      texture1_done:
+		if (offsets != NULL)
+		    FreeMemory(offsets);
 	    }
-	 if (!y_strnicmp (tname, c->name, WAD_TEX_NAME))
-	    texofs = dir->dir.start + offsets[n];
-	 }
-      texture1_done:
-      if (offsets != NULL)
-	 FreeMemory (offsets);
-      }
-   }
-   // Well, then is it in TEXTURE2 ?
-   if (texofs == 0)
-      {
-      const char *lump_name = "TEXTURE2";
-      i32 *offsets = NULL;  // Array of offsets to texture names
+	}
+	// Well, then is it in TEXTURE2 ?
+	if (texofs == 0)
+	{
+	    const char *lump_name = "TEXTURE2";
+	    i32 *offsets = NULL;	// Array of offsets to texture names
 
-      dir = FindMasterDir (MasterDir, lump_name);
-      if (dir != NULL)  // Doom II has no TEXTURE2
-	 {
-	 const Wad_file * wf = dir->wadfile;
-	 wf->seek (dir->dir.start);
-	 if (wf->error ())
+	    dir = FindMasterDir(MasterDir, lump_name);
+	    if (dir != NULL)	// Doom II has no TEXTURE2
 	    {
-	    warn ("%s: can't seek to lump\n", lump_name);
-	    goto texture2_done;
-	    }
-	 wf->read_i32 (&numtex);
-	 if (wf->error ())
-	    {
-	    warn ("%s: error reading texture count\n", lump_name);
-	    goto texture2_done;
+		const Wad_file *wf = dir->wadfile;
+		wf->seek(dir->dir.start);
+		if (wf->error())
+		{
+		    warn("%s: can't seek to lump\n", lump_name);
+		    goto texture2_done;
+		}
+		wf->read_i32(&numtex);
+		if (wf->error())
+		{
+		    warn("%s: error reading texture count\n", lump_name);
+		    goto texture2_done;
+		}
+		// Read in the offsets for TEXTURE2 names
+		offsets = (i32 *) GetMemory((long) numtex * 4);
+		wf->read_i32(offsets, numtex);
+		if (wf->error())
+		{
+		    warn("%s: error reading offsets table\n", lump_name);
+		    goto texture2_done;
+		}
+		for (long n = 0; n < numtex && !texofs; n++)
+		{
+		    wf->seek(dir->dir.start + offsets[n]);
+		    if (wf->error())
+		    {
+			warn("%s: error seeking to definition of texture #%ld\n", lump_name, n);
+			break;
+		    }
+		    wf->read_bytes(&tname, WAD_TEX_NAME);
+		    if (wf->error())
+		    {
+			warn("%s: error reading name of texture #%ld\n",
+			     lump_name, n);
+			break;
+		    }
+		    if (!y_strnicmp(tname, c->name, WAD_TEX_NAME))
+			texofs = dir->dir.start + offsets[n];
+		}
+	      texture2_done:
+		if (offsets != NULL)
+		    FreeMemory(offsets);
 	    }
-	 // Read in the offsets for TEXTURE2 names
-	 offsets = (i32 *) GetMemory ((long) numtex * 4);
-	 wf->read_i32 (offsets, numtex);
-	 if (wf->error ())
-	    {
-	    warn ("%s: error reading offsets table\n", lump_name);
-	    goto texture2_done;
-	    }
-	 for (long n = 0; n < numtex && !texofs; n++)
-	    {
-	    wf->seek (dir->dir.start + offsets[n]);
-	    if (wf->error ())
-	       {
-	       warn ("%s: error seeking to definition of texture #%ld\n",
-		 lump_name, n);
-	       break;
-	       }
-	    wf->read_bytes (&tname, WAD_TEX_NAME);
-	    if (wf->error ())
-	       {
-	       warn ("%s: error reading name of texture #%ld\n", lump_name, n);
-	       break;
-	       }
-	    if (!y_strnicmp (tname, c->name, WAD_TEX_NAME))
-	       texofs = dir->dir.start + offsets[n];
-	    }
-	 texture2_done:
-	 if (offsets != NULL)
-	    FreeMemory (offsets);
-	 }
-      }
-   }
-else
-   nf_bug ("Invalid texture_format/texture_lumps combination.");
+	}
+    }
+    else
+	nf_bug("Invalid texture_format/texture_lumps combination.");
 
 // Texture name not found
-if (texofs == 0)
-   return;
+    if (texofs == 0)
+	return;
 
 // Read the info for this texture
-i32 header_ofs;
-if (yg_texture_format == YGTF_NAMELESS)
-   header_ofs = texofs;
-else
-   header_ofs = texofs + WAD_TEX_NAME;
-dir->wadfile->seek     (header_ofs + 4);
+    i32 header_ofs;
+    if (yg_texture_format == YGTF_NAMELESS)
+	header_ofs = texofs;
+    else
+	header_ofs = texofs + WAD_TEX_NAME;
+    dir->wadfile->seek(header_ofs + 4);
 // FIXME
-dir->wadfile->read_i16 (&width);
+    dir->wadfile->read_i16(&width);
 // FIXME
-dir->wadfile->read_i16 (&height);
+    dir->wadfile->read_i16(&height);
 // FIXME
-if (have_dummy_bytes)
-   {
-   i16 dummy;
-   dir->wadfile->read_i16 (&dummy);
-   dir->wadfile->read_i16 (&dummy);
-   }
-dir->wadfile->read_i16 (&npatches);
+    if (have_dummy_bytes)
+    {
+	i16 dummy;
+	dir->wadfile->read_i16(&dummy);
+	dir->wadfile->read_i16(&dummy);
+    }
+    dir->wadfile->read_i16(&npatches);
 // FIXME
 
-c->width    = width;
-c->height   = height;
-c->npatches = npatches;
-c->flags   |= HOOK_SIZE_VALID | HOOK_DISP_SIZE;
+    c->width = width;
+    c->height = height;
+    c->npatches = npatches;
+    c->flags |= HOOK_SIZE_VALID | HOOK_DISP_SIZE;
 
 /* Clip the texture to size. Done *after* setting c->width and
    c->height so that the selector shows the unclipped size. */
-width  = y_min (width,  c->x1 - c->x0 + 1);
-height = y_min (height, c->y1 - c->y0 + 1);
+    width = y_min(width, c->x1 - c->x0 + 1);
+    height = y_min(height, c->y1 - c->y0 + 1);
 
 // Compose the texture
-c->img.resize (width, height);
-c->img.set_opaque (false);
+    c->img.resize(width, height);
+    c->img.set_opaque(false);
 
 /* Paste onto the buffer all the patches that the texture is
    made of. Unless c->npatches is non-zero, in which case we
    paste only the first maxpatches ones. */
-int maxpatches = npatches;
-if (c->maxpatches != 0 && c->maxpatches <= npatches)
-   maxpatches = c->maxpatches;
-for (n = 0; n < maxpatches; n++)
-   {
-   hookfunc_comm_t subc;
-   i16 xofs, yofs;	// Offset in texture space for the patch
-   i16 pnameind;	// Index of patch in PNAMES
+    int maxpatches = npatches;
+    if (c->maxpatches != 0 && c->maxpatches <= npatches)
+	maxpatches = c->maxpatches;
+    for (n = 0; n < maxpatches; n++)
+    {
+	hookfunc_comm_t subc;
+	i16 xofs, yofs;		// Offset in texture space for the patch
+	i16 pnameind;		// Index of patch in PNAMES
 
-   dir->wadfile->seek (header_ofs + header_size + (long) n * item_size);
-   dir->wadfile->read_i16 (&xofs);
-   dir->wadfile->read_i16 (&yofs);
-   dir->wadfile->read_i16 (&pnameind);
-   if (have_dummy_bytes)
-      {
-      i16 stepdir;
-      i16 colormap;
-      dir->wadfile->read_i16 (&stepdir);   // Always 1, unused.
-      dir->wadfile->read_i16 (&colormap);  // Always 0, unused.
-      }
+	dir->wadfile->seek(header_ofs + header_size + (long) n * item_size);
+	dir->wadfile->read_i16(&xofs);
+	dir->wadfile->read_i16(&yofs);
+	dir->wadfile->read_i16(&pnameind);
+	if (have_dummy_bytes)
+	{
+	    i16 stepdir;
+	    i16 colormap;
+	    dir->wadfile->read_i16(&stepdir);	// Always 1, unused.
+	    dir->wadfile->read_i16(&colormap);	// Always 0, unused.
+	}
+
+	/* AYM 1998-08-08: Yes, that's weird but that's what Doom
+	   does. Without these two lines, the few textures that have
+	   patches with negative y-offsets (BIGDOOR7, SKY1, TEKWALL1,
+	   TEKWALL5 and a few others) would not look in the texture
+	   viewer quite like in Doom. This should be mentioned in
+	   the UDS, by the way. */
+	if (yofs < 0)
+	    yofs = 0;
 
-   /* AYM 1998-08-08: Yes, that's weird but that's what Doom
-      does. Without these two lines, the few textures that have
-      patches with negative y-offsets (BIGDOOR7, SKY1, TEKWALL1,
-      TEKWALL5 and a few others) would not look in the texture
-      viewer quite like in Doom. This should be mentioned in
-      the UDS, by the way. */
-   if (yofs < 0)
-      yofs = 0;
+	Lump_loc loc;
+	{
+	    wad_pic_name_t *name = patch_dir.name_for_num(pnameind);
+	    if (name == 0)
+	    {
+		warn("texture \"%.*s\": patch %2d has bad index %d.\n",
+		     WAD_TEX_NAME, tname, (int) n, (int) pnameind);
+		continue;
+	    }
+	    patch_dir.loc_by_name((const char *) *name, loc);
+	    *picname = '\0';
+	    strncat(picname, (const char *) *name, sizeof picname - 1);
+#ifdef DEBUG
+	    printf("Texture \"%.*s\": Patch %2d: #%3d %-8.8s (%d, %d)\n",
+		   c->name, (int) n, (int) pnameind, picname, (int) xofs,
+		   (int) yofs);
+#endif
+	}
 
-   Lump_loc loc;
-   {
-     wad_pic_name_t *name = patch_dir.name_for_num (pnameind);
-     if (name == 0)
-       {
-       warn ("texture \"%.*s\": patch %2d has bad index %d.\n",
-	  WAD_TEX_NAME, tname, (int) n, (int) pnameind);
-       continue;
-       }
-     patch_dir.loc_by_name ((const char *) *name, loc);
-     *picname = '\0';
-     strncat (picname, (const char *) *name, sizeof picname - 1);
-#ifdef DEBUG
-     printf ("Texture \"%.*s\": Patch %2d: #%3d %-8.8s (%d, %d)\n",
-       c->name, (int) n, (int) pnameind, picname, (int) xofs, (int) yofs);
-#endif
-   }
+	subc.x0 = y_max(c->x0, c->x0 + xofs);
+	subc.y0 = y_min(c->y0, c->y0 + yofs);
+	subc.x1 = c->x1;
+	subc.x1 = c->y1;
+	subc.name = picname;
 
-   subc.x0 = y_max (c->x0, c->x0 + xofs);
-   subc.y0 = y_min (c->y0, c->y0 + yofs);
-   subc.x1 = c->x1;
-   subc.x1 = c->y1;
-   subc.name = picname;
-
-   if (LoadPicture (c->img, picname, loc, xofs, yofs, 0, 0))
-      warn ("texture \"%.*s\": patch \"%.*s\" not found.\n",
-	  WAD_TEX_NAME, tname, WAD_PIC_NAME, picname);
-   }
+	if (LoadPicture(c->img, picname, loc, xofs, yofs, 0, 0))
+	    warn("texture \"%.*s\": patch \"%.*s\" not found.\n",
+		 WAD_TEX_NAME, tname, WAD_PIC_NAME, picname);
+    }
 
 // Display the texture
-Sticker sticker (c->img, true);		// Use opaque because it's faster
-sticker.draw (drw, 't', c->x0, c->y0);
-c->flags |= HOOK_DRAWN;
-c->disp_x0 = c->x0 + c->xofs;
-c->disp_y0 = c->y0 + c->yofs;
-c->disp_x1 = c->disp_x0 + width - 1;
-c->disp_y1 = c->disp_y0 + height - 1;
+    Sticker sticker(c->img, true);	// Use opaque because it's faster
+    sticker.draw(drw, 't', c->x0, c->y0);
+    c->flags |= HOOK_DRAWN;
+    c->disp_x0 = c->x0 + c->xofs;
+    c->disp_y0 = c->y0 + c->yofs;
+    c->disp_x1 = c->disp_x0 + width - 1;
+    c->disp_y1 = c->disp_y0 + height - 1;
 }
 
 
 /*
    Function to get the size of a wall texture
 */
-void GetWallTextureSize (i16 *width, i16 *height, const char *texname)
+void GetWallTextureSize(i16 * width, i16 * height, const char *texname)
 {
-MDirPtr  dir = 0;			// Pointer in main directory to texname
-i32    *offsets;			// Array of offsets to texture names
-int      n;				// General counter
-i32      numtex;			// Number of texture names in TEXTURE*
-i32      texofs;			// Offset in wad for the texture data
-char     tname[WAD_TEX_NAME + 1];	// Texture name
+    MDirPtr dir = 0;		// Pointer in main directory to texname
+    i32 *offsets;		// Array of offsets to texture names
+    int n;			// General counter
+    i32 numtex;			// Number of texture names in TEXTURE*
+    i32 texofs;			// Offset in wad for the texture data
+    char tname[WAD_TEX_NAME + 1];	// Texture name
 
 // Offset for texture we want
-texofs = 0;
+    texofs = 0;
 // Search for texname in TEXTURE1 (or TEXTURES)
-if (yg_texture_lumps == YGTL_TEXTURES && yg_texture_format == YGTF_NAMELESS)
-   {
-   dir = FindMasterDir (MasterDir, "TEXTURES");
-   if (dir != NULL)
-      {
-      dir->wadfile->seek (dir->dir.start);
-      dir->wadfile->read_i32 (&numtex);
-      if (WAD_TEX_NAME < 7) nf_bug ("WAD_TEX_NAME too small");  // Sanity
-      if (! y_strnicmp (texname, "TEX", 3)
-	    && isdigit (texname[3])
-	    && isdigit (texname[4])
-	    && isdigit (texname[5])
-	    && isdigit (texname[6])
-	    && texname[7] == '\0')
-	 {
-	 long num;
-	 if (sscanf (texname + 3, "%4ld", &num) == 1
-	       && num >= 0 && num < numtex)
+    if (yg_texture_lumps == YGTL_TEXTURES
+	&& yg_texture_format == YGTF_NAMELESS)
+    {
+	dir = FindMasterDir(MasterDir, "TEXTURES");
+	if (dir != NULL)
+	{
+	    dir->wadfile->seek(dir->dir.start);
+	    dir->wadfile->read_i32(&numtex);
+	    if (WAD_TEX_NAME < 7)
+		nf_bug("WAD_TEX_NAME too small");	// Sanity
+	    if (!y_strnicmp(texname, "TEX", 3)
+		&& isdigit(texname[3])
+		&& isdigit(texname[4])
+		&& isdigit(texname[5])
+		&& isdigit(texname[6]) && texname[7] == '\0')
 	    {
-	    dir->wadfile->seek (dir->dir.start + 4 + 4 * num);
-	    dir->wadfile->read_i32 (&texofs);
+		long num;
+		if (sscanf(texname + 3, "%4ld", &num) == 1
+		    && num >= 0 && num < numtex)
+		{
+		    dir->wadfile->seek(dir->dir.start + 4 + 4 * num);
+		    dir->wadfile->read_i32(&texofs);
+		}
 	    }
-	 }
-      }
-   }
-else if (yg_texture_format == YGTF_NORMAL
-    || yg_texture_format == YGTF_STRIFE11)
-   {
-   if (yg_texture_lumps == YGTL_TEXTURES)
-      dir = FindMasterDir (MasterDir, "TEXTURES");  // Doom alpha 0.5
-   else if (yg_texture_lumps == YGTL_NORMAL)
-      dir = FindMasterDir (MasterDir, "TEXTURE1");
-   else
-      {
-      dir = 0;
-      nf_bug ("Invalid texture_format/texture_lumps combination.");
-      }
-   if (dir != NULL)
-      {
-      dir->wadfile->seek (dir->dir.start);
-      dir->wadfile->read_i32 (&numtex);
-      // Read in the offsets for texture1 names and info
-      offsets = (i32 *) GetMemory ((long) numtex * 4);
-      dir->wadfile->read_i32 (offsets, numtex);
-      for (n = 0; n < numtex && !texofs; n++)
-	 {
-	 dir->wadfile->seek (dir->dir.start + offsets[n]);
-	 dir->wadfile->read_bytes (&tname, WAD_TEX_NAME);
-	 if (!y_strnicmp (tname, texname, WAD_TEX_NAME))
-	    texofs = dir->dir.start + offsets[n];
-	 }
-      FreeMemory (offsets);
-      }
-   if (texofs == 0 && yg_texture_lumps == YGTL_NORMAL)
-      {
-      // Search for texname in TEXTURE2
-      dir = FindMasterDir (MasterDir, "TEXTURE2");
-      if (dir != NULL)  // Doom II has no TEXTURE2
-	 {
-	 dir->wadfile->seek (dir->dir.start);
-	 dir->wadfile->read_i32 (&numtex);
-	 // Read in the offsets for texture2 names
-	 offsets = (i32 *) GetMemory ((long) numtex * 4);
-	 dir->wadfile->read_i32 (offsets);
-	 for (n = 0; n < numtex && !texofs; n++)
+	}
+    }
+    else if (yg_texture_format == YGTF_NORMAL
+	     || yg_texture_format == YGTF_STRIFE11)
+    {
+	if (yg_texture_lumps == YGTL_TEXTURES)
+	    dir = FindMasterDir(MasterDir, "TEXTURES");	// Doom alpha 0.5
+	else if (yg_texture_lumps == YGTL_NORMAL)
+	    dir = FindMasterDir(MasterDir, "TEXTURE1");
+	else
+	{
+	    dir = 0;
+	    nf_bug("Invalid texture_format/texture_lumps combination.");
+	}
+	if (dir != NULL)
+	{
+	    dir->wadfile->seek(dir->dir.start);
+	    dir->wadfile->read_i32(&numtex);
+	    // Read in the offsets for texture1 names and info
+	    offsets = (i32 *) GetMemory((long) numtex * 4);
+	    dir->wadfile->read_i32(offsets, numtex);
+	    for (n = 0; n < numtex && !texofs; n++)
+	    {
+		dir->wadfile->seek(dir->dir.start + offsets[n]);
+		dir->wadfile->read_bytes(&tname, WAD_TEX_NAME);
+		if (!y_strnicmp(tname, texname, WAD_TEX_NAME))
+		    texofs = dir->dir.start + offsets[n];
+	    }
+	    FreeMemory(offsets);
+	}
+	if (texofs == 0 && yg_texture_lumps == YGTL_NORMAL)
+	{
+	    // Search for texname in TEXTURE2
+	    dir = FindMasterDir(MasterDir, "TEXTURE2");
+	    if (dir != NULL)	// Doom II has no TEXTURE2
 	    {
-	    dir->wadfile->seek (dir->dir.start + offsets[n]);
-	    dir->wadfile->read_bytes (&tname, WAD_TEX_NAME);
-	    if (!y_strnicmp (tname, texname, WAD_TEX_NAME))
-	       texofs = dir->dir.start + offsets[n];
+		dir->wadfile->seek(dir->dir.start);
+		dir->wadfile->read_i32(&numtex);
+		// Read in the offsets for texture2 names
+		offsets = (i32 *) GetMemory((long) numtex * 4);
+		dir->wadfile->read_i32(offsets);
+		for (n = 0; n < numtex && !texofs; n++)
+		{
+		    dir->wadfile->seek(dir->dir.start + offsets[n]);
+		    dir->wadfile->read_bytes(&tname, WAD_TEX_NAME);
+		    if (!y_strnicmp(tname, texname, WAD_TEX_NAME))
+			texofs = dir->dir.start + offsets[n];
+		}
+		FreeMemory(offsets);
 	    }
-	 FreeMemory (offsets);
-	 }
-      }
-   }
-else
-   nf_bug ("Invalid texture_format/texture_lumps combination.");
+	}
+    }
+    else
+	nf_bug("Invalid texture_format/texture_lumps combination.");
 
-if (texofs != 0)
-   {
-   // Read the info for this texture
-   if (yg_texture_format == YGTF_NAMELESS)
-      dir->wadfile->seek (texofs + 4L);
-   else
-      dir->wadfile->seek (texofs + 12L);
-   dir->wadfile->read_i16 (width);
-   dir->wadfile->read_i16 (height);
-   }
-else
-   {
-   // Texture data not found
-   *width  = -1;
-   *height = -1;
-   }
+    if (texofs != 0)
+    {
+	// Read the info for this texture
+	if (yg_texture_format == YGTF_NAMELESS)
+	    dir->wadfile->seek(texofs + 4L);
+	else
+	    dir->wadfile->seek(texofs + 12L);
+	dir->wadfile->read_i16(width);
+	dir->wadfile->read_i16(height);
+    }
+    else
+    {
+	// Texture data not found
+	*width = -1;
+	*height = -1;
+    }
 }
 
 
 /*
    choose a wall texture
 */
-void ChooseWallTexture (int x0, int y0, const char *prompt, int listsize,
-   char **list, char *name)
+void ChooseWallTexture(int x0, int y0, const char *prompt, int listsize,
+		       char **list, char *name)
 {
-InputNameFromListWithFunc (x0, y0, prompt, listsize, list, 9, name,
-  512, 256, DisplayWallTexture);
+    InputNameFromListWithFunc(x0, y0, prompt, listsize, list, 9, name,
+			      512, 256, DisplayWallTexture);
 
 }
-
--- a/src/textures.h	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/textures.h	Sat Sep 24 14:16:04 2011 +0300
@@ -4,7 +4,7 @@
  */
 
 
-#ifndef YH_TEXTURES  /* DO NOT ADD ANYTHING BEFORE THIS LINE */
+#ifndef YH_TEXTURES		/* DO NOT ADD ANYTHING BEFORE THIS LINE */
 #define YH_TEXTURES
 
 
@@ -12,9 +12,9 @@
 
 
 /* textures.cc */
-void DisplayPic (hookfunc_comm_t *c);
-void ChooseWallTexture (int, int, const char *, int, char **, char *);
-void GetWallTextureSize (i16 *, i16 *, const char *);
+void DisplayPic(hookfunc_comm_t * c);
+void ChooseWallTexture(int, int, const char *, int, char **, char *);
+void GetWallTextureSize(i16 *, i16 *, const char *);
 
 
 #endif
--- a/src/things.cc	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/things.cc	Sat Sep 24 14:16:04 2011 +0300
@@ -41,22 +41,22 @@
 // It is searched in a dichotomic fashion by get_thing_*().
 // This table is only here for speed.
 typedef struct
-  {
-  wad_ttype_t type;
-  char		flags;
-  short         radius;
-  acolour_t     colour;
-  const char    *desc;
-  const char	*sprite;
-  } thing_attributes_t;
+{
+    wad_ttype_t type;
+    char flags;
+    short radius;
+    acolour_t colour;
+    const char *desc;
+    const char *sprite;
+} thing_attributes_t;
 
 static thing_attributes_t *things_table;
 static size_t nthings;
 int _max_radius;
-static size_t last_table_idx = (size_t) -1;
+static size_t last_table_idx = (size_t) - 1;
 
 
-static int things_table_cmp (const void *a, const void *b);
+static int things_table_cmp(const void *a, const void *b);
 
 
 static const int default_radius = 16;
@@ -68,53 +68,54 @@
  *	that's used by get_thing_*() to speed things up.
  *	Call delete_things_table to delete that table.
  */
-void create_things_table ()
+void create_things_table()
 {
-size_t n;
+    size_t n;
 
-_max_radius = default_radius;
-nthings = al_lcount (thingdef);
-if (nthings == 0)
-   {
-   things_table = NULL;
-   return;
-   }
-things_table = (thing_attributes_t *) malloc (nthings * sizeof *things_table);
-if (! things_table)
-   fatal_error ("Not enough memory");
-for (al_lrewind (thingdef), n = 0; n < nthings; al_lstep (thingdef), n++)
-   {
-   things_table[n].type   = CUR_THINGDEF->number;
-   things_table[n].flags  = CUR_THINGDEF->flags;
-   things_table[n].radius = CUR_THINGDEF->radius;
-   _max_radius = y_max (_max_radius, CUR_THINGDEF->radius);
+    _max_radius = default_radius;
+    nthings = al_lcount(thingdef);
+    if (nthings == 0)
+    {
+	things_table = NULL;
+	return;
+    }
+    things_table =
+	(thing_attributes_t *) malloc(nthings * sizeof *things_table);
+    if (!things_table)
+	fatal_error("Not enough memory");
+    for (al_lrewind(thingdef), n = 0; n < nthings; al_lstep(thingdef), n++)
+    {
+	things_table[n].type = CUR_THINGDEF->number;
+	things_table[n].flags = CUR_THINGDEF->flags;
+	things_table[n].radius = CUR_THINGDEF->radius;
+	_max_radius = y_max(_max_radius, CUR_THINGDEF->radius);
 
-   // Fetch the app colour no. for the thinggroup
-   for (al_lrewind (thinggroup); ! al_leol (thinggroup); al_lstep (thinggroup))
-      {
-      if (CUR_THINGGROUP  /* don't segfault if zero thinggroup ! */
-       && CUR_THINGGROUP->thinggroup == CUR_THINGDEF->thinggroup)
-	 {
-	 things_table[n].colour = CUR_THINGGROUP->acn;
-	 break;
-	 }
-      }
+	// Fetch the app colour no. for the thinggroup
+	for (al_lrewind(thinggroup); !al_leol(thinggroup);
+	     al_lstep(thinggroup))
+	{
+	    if (CUR_THINGGROUP	/* don't segfault if zero thinggroup ! */
+		&& CUR_THINGGROUP->thinggroup == CUR_THINGDEF->thinggroup)
+	    {
+		things_table[n].colour = CUR_THINGGROUP->acn;
+		break;
+	    }
+	}
 
-   things_table[n].desc   = CUR_THINGDEF->desc;
-   things_table[n].sprite = CUR_THINGDEF->sprite;
-   }
+	things_table[n].desc = CUR_THINGDEF->desc;
+	things_table[n].sprite = CUR_THINGDEF->sprite;
+    }
 
 // Sort the table by increasing thing type
-qsort (things_table, nthings, sizeof *things_table, things_table_cmp);
+    qsort(things_table, nthings, sizeof *things_table, things_table_cmp);
 
 #if 0
-printf ("Type  Colour Radius Desc\n");
-for (n = 0; n < nthings; n++)
-   printf ("%5d %-6d %3d    %s\n",
-      things_table[n].type,
-      things_table[n].colour,
-      things_table[n].radius,
-      things_table[n].desc);
+    printf("Type  Colour Radius Desc\n");
+    for (n = 0; n < nthings; n++)
+	printf("%5d %-6d %3d    %s\n",
+	       things_table[n].type,
+	       things_table[n].colour,
+	       things_table[n].radius, things_table[n].desc);
 #endif
 }
 
@@ -123,13 +124,13 @@
  *	delete_things_table
  *	Free what create_things_table() allocated.
  */
-void delete_things_table (void)
+void delete_things_table(void)
 {
-if (things_table)
-   {
-   free (things_table);
-   nthings = 0;
-   }
+    if (things_table)
+    {
+	free(things_table);
+	nthings = 0;
+    }
 }
 
 
@@ -138,10 +139,10 @@
  *	Used by create_things_table() to sort the table
  *	by increasing THING type.
  */
-static int things_table_cmp (const void *a, const void *b)
+static int things_table_cmp(const void *a, const void *b)
 {
-return ((const thing_attributes_t *) a)->type
-     - ((const thing_attributes_t *) b)->type;
+    return ((const thing_attributes_t *) a)->type
+	- ((const thing_attributes_t *) b)->type;
 }
 
 
@@ -155,37 +156,37 @@
  *	attributes of the same thing type are queried in a row,
  *	the table search is done only once.
  */
-inline int lookup_thing (wad_ttype_t type)
+inline int lookup_thing(wad_ttype_t type)
 {
-if (last_table_idx < nthings && things_table[last_table_idx].type == type)
-   return last_table_idx;
+    if (last_table_idx < nthings && things_table[last_table_idx].type == type)
+	return last_table_idx;
 
-if (things_table == NULL)
-   return (size_t) -1;
+    if (things_table == NULL)
+	return (size_t) - 1;
 
-size_t nmin = 0;
-size_t nmax = nthings - 1;
-for (;;)
-   {
-   last_table_idx = (nmin + nmax) / 2;
-   if (type > things_table[last_table_idx].type)
-      {
-      if (nmin >= nmax)
-         break;
-      nmin = last_table_idx + 1;
-      }
-   else if (type < things_table[last_table_idx].type)
-      {
-      if (nmin >= nmax)
-         break;
-      if (last_table_idx < 1)
-         break;
-      nmax = last_table_idx - 1;
-      }
-   else
-      return last_table_idx;
-   }
-return (size_t) -1;
+    size_t nmin = 0;
+    size_t nmax = nthings - 1;
+    for (;;)
+    {
+	last_table_idx = (nmin + nmax) / 2;
+	if (type > things_table[last_table_idx].type)
+	{
+	    if (nmin >= nmax)
+		break;
+	    nmin = last_table_idx + 1;
+	}
+	else if (type < things_table[last_table_idx].type)
+	{
+	    if (nmin >= nmax)
+		break;
+	    if (last_table_idx < 1)
+		break;
+	    nmax = last_table_idx - 1;
+	}
+	else
+	    return last_table_idx;
+    }
+    return (size_t) - 1;
 }
 
 
@@ -194,10 +195,10 @@
  *
  *	Return true if the thing is defined, false otherwise.
  */
-bool is_thing_type (wad_ttype_t type)
+bool is_thing_type(wad_ttype_t type)
 {
-size_t table_idx = lookup_thing (type);
-return table_idx < nthings;
+    size_t table_idx = lookup_thing(type);
+    return table_idx < nthings;
 }
 
 
@@ -206,30 +207,30 @@
  *
  *	Return the colour. If the 
  */
-acolour_t get_thing_colour (wad_ttype_t type)
+acolour_t get_thing_colour(wad_ttype_t type)
 {
-size_t table_idx = lookup_thing (type);
-if (table_idx == (size_t) -1)
-   return LIGHTCYAN;  // Not found.
-else
-   return things_table[table_idx].colour;
+    size_t table_idx = lookup_thing(type);
+    if (table_idx == (size_t) - 1)
+	return LIGHTCYAN;	// Not found.
+    else
+	return things_table[table_idx].colour;
 }
 
 
 /*
  *	get_thing_name - return the description of the thing of given type.
  */
-const char *get_thing_name (wad_ttype_t type)
+const char *get_thing_name(wad_ttype_t type)
 {
-size_t table_idx = lookup_thing (type);
-if (table_idx == (size_t) -1)
-   {
-   static char buf[20];
-   sprintf (buf, "UNKNOWN (%d)", type);  // Not found.
-   return buf;
-   }
-else
-   return things_table[table_idx].desc;
+    size_t table_idx = lookup_thing(type);
+    if (table_idx == (size_t) - 1)
+    {
+	static char buf[20];
+	sprintf(buf, "UNKNOWN (%d)", type);	// Not found.
+	return buf;
+    }
+    else
+	return things_table[table_idx].desc;
 }
 
 
@@ -237,13 +238,13 @@
  *	get_thing_sprite
  *	Return the root of the sprite name for the thing of given type.
  */
-const char *get_thing_sprite (wad_ttype_t type)
+const char *get_thing_sprite(wad_ttype_t type)
 {
-size_t table_idx = lookup_thing (type);
-if (table_idx == (size_t) -1)
-   return NULL;  // Not found
-else
-   return things_table[table_idx].sprite;
+    size_t table_idx = lookup_thing(type);
+    if (table_idx == (size_t) - 1)
+	return NULL;		// Not found
+    else
+	return things_table[table_idx].sprite;
 }
 
 
@@ -251,13 +252,13 @@
  *	get_thing_flags
  *	Return the flags for the thing of given type.
  */
-char get_thing_flags (wad_ttype_t type)
+char get_thing_flags(wad_ttype_t type)
 {
-size_t table_idx = lookup_thing (type);
-if (table_idx == (size_t) -1)
-   return 0;  // Not found
-else
-   return things_table[table_idx].flags;
+    size_t table_idx = lookup_thing(type);
+    if (table_idx == (size_t) - 1)
+	return 0;		// Not found
+    else
+	return things_table[table_idx].flags;
 }
 
 
@@ -265,13 +266,13 @@
  *	get_thing_radius
  *	Return the radius of the thing of given type.
  */
-int get_thing_radius (wad_ttype_t type)
+int get_thing_radius(wad_ttype_t type)
 {
-size_t table_idx = lookup_thing (type);
-if (table_idx == (size_t) -1)
-   return default_radius;  // Not found.
-else
-   return things_table[table_idx].radius;
+    size_t table_idx = lookup_thing(type);
+    if (table_idx == (size_t) - 1)
+	return default_radius;	// Not found.
+    else
+	return things_table[table_idx].radius;
 }
 
 
@@ -295,31 +296,31 @@
  *	GetAngleName
  *	Get the name of the angle
  */
-const char *GetAngleName (int angle)
+const char *GetAngleName(int angle)
 {
-static char buf[30];
+    static char buf[30];
 
-switch (angle)
-   {
-   case 0:
-      return "East";
-   case 45:
-      return "North-east";
-   case 90:
-      return "North";
-   case 135:
-      return "North-west";
-   case 180:
-      return "West";
-   case 225:
-      return "South-west";
-   case 270:
-      return "South";
-   case 315:
-      return "South-east";
-   }
-sprintf (buf, "ILLEGAL (%d)", angle);
-return buf;
+    switch (angle)
+    {
+    case 0:
+	return "East";
+    case 45:
+	return "North-east";
+    case 90:
+	return "North";
+    case 135:
+	return "North-west";
+    case 180:
+	return "West";
+    case 225:
+	return "South-west";
+    case 270:
+	return "South";
+    case 315:
+	return "South-east";
+    }
+    sprintf(buf, "ILLEGAL (%d)", angle);
+    return buf;
 }
 
 
@@ -327,68 +328,65 @@
  *	GetWhenName
  *	get string of when something will appear
  */
-const char *GetWhenName (int when)
+const char *GetWhenName(int when)
 {
-static char buf[16+3+1];
+    static char buf[16 + 3 + 1];
 // "N" is a Boom extension ("not in deathmatch")
 // "C" is a Boom extension ("not in cooperative")
 // "F" is an MBF extension ("friendly")
-const char *flag_chars = "????" "????" "FCNM" "D431";
-int n;
+    const char *flag_chars = "????" "????" "FCNM" "D431";
+    int n;
 
-char *b = buf;
-for (n = 0; n < 16; n++)
-   {
-   if (n != 0 && n % 4 == 0)
-      *b++ = ' ';
-   if (when & (0x8000u >> n))
-      *b++ = flag_chars[n];
-   else
-      *b++ = '-';
-   }
-*b = '\0';
-return buf;
+    char *b = buf;
+    for (n = 0; n < 16; n++)
+    {
+	if (n != 0 && n % 4 == 0)
+	    *b++ = ' ';
+	if (when & (0x8000u >> n))
+	    *b++ = flag_chars[n];
+	else
+	    *b++ = '-';
+    }
+    *b = '\0';
+    return buf;
 
 #if 0
-static char buf[30];
-char *ptr = buf;
-*ptr = '\0';
-if (when & 0x01)
-   {
-   strcpy (ptr, "D12");
-   ptr += 3;
-   }
-if (when & 0x02)
-   {
-   if (ptr != buf)
-      *ptr++ = ' ';
-   strcpy (ptr, "D3");
-   ptr += 2;
-   }
-if (when & 0x04)
-   {
-   if (ptr != buf)
-      *ptr++ = ' ';
-   strcpy (ptr, "D45");
-   ptr += 3;
-   }
-if (when & 0x08)
-   {
-   if (ptr != buf)
-      *ptr++ = ' ';
-   strcpy (ptr, "Deaf");
-   ptr += 4;
-   }
-if (when & 0x10)
-   {
-   if (ptr != buf)
-      *ptr++ = ' ';
-   strcpy (ptr, "Multi");
-   ptr += 5;
-   }
-return buf;
+    static char buf[30];
+    char *ptr = buf;
+    *ptr = '\0';
+    if (when & 0x01)
+    {
+	strcpy(ptr, "D12");
+	ptr += 3;
+    }
+    if (when & 0x02)
+    {
+	if (ptr != buf)
+	    *ptr++ = ' ';
+	strcpy(ptr, "D3");
+	ptr += 2;
+    }
+    if (when & 0x04)
+    {
+	if (ptr != buf)
+	    *ptr++ = ' ';
+	strcpy(ptr, "D45");
+	ptr += 3;
+    }
+    if (when & 0x08)
+    {
+	if (ptr != buf)
+	    *ptr++ = ' ';
+	strcpy(ptr, "Deaf");
+	ptr += 4;
+    }
+    if (when & 0x10)
+    {
+	if (ptr != buf)
+	    *ptr++ = ' ';
+	strcpy(ptr, "Multi");
+	ptr += 5;
+    }
+    return buf;
 #endif
 }
-
-
-
--- a/src/things.h	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/things.h	Sat Sep 24 14:16:04 2011 +0300
@@ -5,8 +5,8 @@
  */
 
 
-#ifndef YH_THINGS  /* Prevent multiple inclusion */
-#define YH_THINGS  /* Prevent multiple inclusion */
+#ifndef YH_THINGS		/* Prevent multiple inclusion */
+#define YH_THINGS		/* Prevent multiple inclusion */
 
 
 #include "wstructs.h"
@@ -22,22 +22,26 @@
 
 extern
 #ifndef YC_THINGS
-const
+    const
 #endif
 int _max_radius;
 
 
-void        create_things_table ();
-void        delete_things_table ();
-bool        is_thing_type    (wad_ttype_t type);
-acolour_t   get_thing_colour (wad_ttype_t type);
-const char *get_thing_name   (wad_ttype_t type);
-const char *get_thing_sprite (wad_ttype_t type);
-char        get_thing_flags  (wad_ttype_t type);
-int         get_thing_radius (wad_ttype_t type);
-inline int  get_max_thing_radius () { return _max_radius; }
-const char *GetAngleName (int);
-const char *GetWhenName (int);
+void create_things_table();
+void delete_things_table();
+bool is_thing_type(wad_ttype_t type);
+acolour_t get_thing_colour(wad_ttype_t type);
+const char *get_thing_name(wad_ttype_t type);
+const char *get_thing_sprite(wad_ttype_t type);
+char get_thing_flags(wad_ttype_t type);
+int get_thing_radius(wad_ttype_t type);
+inline int get_max_thing_radius()
+{
+    return _max_radius;
+}
+
+const char *GetAngleName(int);
+const char *GetWhenName(int);
 
 
 /*
@@ -45,12 +49,10 @@
  *
  *	Return a value that is guaranteed to be within [0-7].
  */
-inline int angle_to_direction (wad_tangle_t angle)
+inline int angle_to_direction(wad_tangle_t angle)
 {
-  return ((unsigned) angle / 45) % 8;
+    return ((unsigned) angle / 45) % 8;
 }
 
 
-#endif  /* Prevent multiple inclusion */
-
-
+#endif /* Prevent multiple inclusion */
--- a/src/trace.cc	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/trace.cc	Sat Sep 24 14:16:04 2011 +0300
@@ -33,18 +33,16 @@
 
 
 // FIXME stopgap
-void trace (const char *domain, const char *fmt, ...)
+void trace(const char *domain, const char *fmt, ...)
 {
-  if (verbose)
-  {
-    va_list args;
+    if (verbose)
+    {
+	va_list args;
 
-    fprintf (stdout, "%s: ", domain);
-    va_start (args, fmt);
-    vprintf (fmt, args);
-    va_end (args);
-    putchar ('\n');
-  }
+	fprintf(stdout, "%s: ", domain);
+	va_start(args, fmt);
+	vprintf(fmt, args);
+	va_end(args);
+	putchar('\n');
+    }
 }
-
-
--- a/src/trace.h	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/trace.h	Sat Sep 24 14:16:04 2011 +0300
@@ -33,7 +33,7 @@
 
 
 // FIXME stopgap
-void trace (const char *domain, const char *fmt, ...);
+void trace(const char *domain, const char *fmt, ...);
 
 
-#endif  /* DO NOT ADD ANYTHING AFTER THIS LINE */
+#endif /* DO NOT ADD ANYTHING AFTER THIS LINE */
--- a/src/v_centre.cc	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/v_centre.cc	Sat Sep 24 14:16:04 2011 +0300
@@ -38,30 +38,30 @@
  *	centre_of_vertices
  *	Return the coordinates of the centre of a group of vertices.
  */
-void centre_of_vertices (SelPtr list, int *x, int *y)
+void centre_of_vertices(SelPtr list, int *x, int *y)
 {
-SelPtr cur;
-int nitems;
-long x_sum;
-long y_sum;
+    SelPtr cur;
+    int nitems;
+    long x_sum;
+    long y_sum;
 
-x_sum = 0;
-y_sum = 0;
-for (nitems = 0, cur = list; cur; cur = cur->next, nitems++)
-   {
-   x_sum += Vertices[cur->objnum].x;
-   y_sum += Vertices[cur->objnum].y;
-   }
-if (nitems == 0)
-   {
-   *x = 0;
-   *y = 0;
-   }
-else
-   {
-   *x = (int) (x_sum / nitems);
-   *y = (int) (y_sum / nitems);
-   }
+    x_sum = 0;
+    y_sum = 0;
+    for (nitems = 0, cur = list; cur; cur = cur->next, nitems++)
+    {
+	x_sum += Vertices[cur->objnum].x;
+	y_sum += Vertices[cur->objnum].y;
+    }
+    if (nitems == 0)
+    {
+	*x = 0;
+	*y = 0;
+    }
+    else
+    {
+	*x = (int) (x_sum / nitems);
+	*y = (int) (y_sum / nitems);
+    }
 }
 
 
@@ -69,31 +69,29 @@
  *	centre_of_vertices
  *	Return the coordinates of the centre of a group of vertices.
  */
-void centre_of_vertices (const bitvec_c &bv, int &x, int &y)
+void centre_of_vertices(const bitvec_c & bv, int &x, int &y)
 {
-long x_sum = 0;
-long y_sum = 0;
-int nmax = bv.nelements ();
-int nvertices = 0;
-for (int n = 0; n < nmax; n++)
-   {
-   if (bv.get (n))
-      {
-      x_sum += Vertices[n].x;
-      y_sum += Vertices[n].y;
-      nvertices++;
-      }
-   }
-if (nvertices == 0)
-   {
-   x = 0;
-   y = 0;
-   }
-else
-   {
-   x = (int) (x_sum / nvertices);
-   y = (int) (y_sum / nvertices);
-   }
+    long x_sum = 0;
+    long y_sum = 0;
+    int nmax = bv.nelements();
+    int nvertices = 0;
+    for (int n = 0; n < nmax; n++)
+    {
+	if (bv.get(n))
+	{
+	    x_sum += Vertices[n].x;
+	    y_sum += Vertices[n].y;
+	    nvertices++;
+	}
+    }
+    if (nvertices == 0)
+    {
+	x = 0;
+	y = 0;
+    }
+    else
+    {
+	x = (int) (x_sum / nvertices);
+	y = (int) (y_sum / nvertices);
+    }
 }
-
-
--- a/src/v_centre.h	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/v_centre.h	Sat Sep 24 14:16:04 2011 +0300
@@ -4,7 +4,5 @@
  */
 
 
-void centre_of_vertices (SelPtr list, int *x, int *y);
-void centre_of_vertices (const bitvec_c &bv, int &x, int &y);
-
-
+void centre_of_vertices(SelPtr list, int *x, int *y);
+void centre_of_vertices(const bitvec_c & bv, int &x, int &y);
--- a/src/v_merge.cc	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/v_merge.cc	Sat Sep 24 14:16:04 2011 +0300
@@ -36,65 +36,65 @@
 #include "selectn.h"
 
 
-typedef struct  /* Used only by AutoMergeVertices() and SortLinedefs() */
-  {
-  int vertexl;
-  int vertexh;
-  int linedefno;
-  } linedef_t;
+typedef struct			/* Used only by AutoMergeVertices() and SortLinedefs() */
+{
+    int vertexl;
+    int vertexh;
+    int linedefno;
+} linedef_t;
 
 /* Called only by AutoMergeVertices() */
-static int SortLinedefs  (const void *item1, const void *item2);
+static int SortLinedefs(const void *item1, const void *item2);
 
 
 /*
    delete a vertex and join the two linedefs
 */
 
-void DeleteVerticesJoinLineDefs (SelPtr obj)
+void DeleteVerticesJoinLineDefs(SelPtr obj)
 {
-int    lstart, lend, l;
-SelPtr cur;
-char   msg[80];
+    int lstart, lend, l;
+    SelPtr cur;
+    char msg[80];
 
-while (obj != NULL)
-   {
-   cur = obj;
-   obj = obj->next;
-   lstart = -1;
-   lend = -1;
-   for (l = 0; l < NumLineDefs; l++)
-      {
-      if (LineDefs[l].start == cur->objnum)
-	 {
-	 if (lstart == -1)
-	    lstart = l;
-	 else
-	    lstart = -2;
-	 }
-      if (LineDefs[l].end == cur->objnum)
-	 {
-	 if (lend == -1)
-	    lend = l;
-	 else
-	    lend = -2;
-	 }
-      }
-   if (lstart < 0 || lend < 0)
-      {
-      Beep ();
-      sprintf (msg, "Cannot delete vertex #%d and join the linedefs",
-	cur->objnum);
-      Notify (-1, -1, msg, "The vertex must be the start of one linedef"
-	" and the end of another one");
-      continue;
-      }
-   LineDefs[lend].end = LineDefs[lstart].end;
-   DeleteObject (Objid (OBJ_LINEDEFS, lstart));
-   DeleteObject (Objid (OBJ_VERTICES, cur->objnum));
-   MadeChanges = 1;
-   MadeMapChanges = 1;
-   }
+    while (obj != NULL)
+    {
+	cur = obj;
+	obj = obj->next;
+	lstart = -1;
+	lend = -1;
+	for (l = 0; l < NumLineDefs; l++)
+	{
+	    if (LineDefs[l].start == cur->objnum)
+	    {
+		if (lstart == -1)
+		    lstart = l;
+		else
+		    lstart = -2;
+	    }
+	    if (LineDefs[l].end == cur->objnum)
+	    {
+		if (lend == -1)
+		    lend = l;
+		else
+		    lend = -2;
+	    }
+	}
+	if (lstart < 0 || lend < 0)
+	{
+	    Beep();
+	    sprintf(msg, "Cannot delete vertex #%d and join the linedefs",
+		    cur->objnum);
+	    Notify(-1, -1, msg, "The vertex must be the start of one linedef"
+		   " and the end of another one");
+	    continue;
+	}
+	LineDefs[lend].end = LineDefs[lstart].end;
+	DeleteObject(Objid(OBJ_LINEDEFS, lstart));
+	DeleteObject(Objid(OBJ_VERTICES, cur->objnum));
+	MadeChanges = 1;
+	MadeMapChanges = 1;
+    }
 }
 
 
@@ -103,38 +103,38 @@
    merge several vertices into one
 */
 
-void MergeVertices (SelPtr *list)
+void MergeVertices(SelPtr * list)
 {
-int    v, l;
+    int v, l;
 
-v = (*list)->objnum;
-UnSelectObject (list, v);
-if (*list == NULL)
-   {
-   Beep ();
-   Notify (-1, -1, "You must select at least two vertices", NULL);
-   return;
-   }
+    v = (*list)->objnum;
+    UnSelectObject(list, v);
+    if (*list == NULL)
+    {
+	Beep();
+	Notify(-1, -1, "You must select at least two vertices", NULL);
+	return;
+    }
 /* change the linedefs starts & ends */
-for (l = 0; l < NumLineDefs; l++)
-   {
-   if (IsSelected (*list, LineDefs[l].start))
-      {
-      /* don't change a linedef that has both ends on the same spot */
-      if (!IsSelected (*list, LineDefs[l].end) && LineDefs[l].end != v)
-	 LineDefs[l].start = v;
-      }
-   else if (IsSelected (*list, LineDefs[l].end))
-      {
-      /* idem */
-      if (LineDefs[l].start != v)
-	 LineDefs[l].end = v;
-      }
-   }
+    for (l = 0; l < NumLineDefs; l++)
+    {
+	if (IsSelected(*list, LineDefs[l].start))
+	{
+	    /* don't change a linedef that has both ends on the same spot */
+	    if (!IsSelected(*list, LineDefs[l].end) && LineDefs[l].end != v)
+		LineDefs[l].start = v;
+	}
+	else if (IsSelected(*list, LineDefs[l].end))
+	{
+	    /* idem */
+	    if (LineDefs[l].start != v)
+		LineDefs[l].end = v;
+	}
+    }
 /* delete the vertices (and some linedefs too) */
-DeleteObjects (OBJ_VERTICES, list);
-MadeChanges = 1;
-MadeMapChanges = 1;
+    DeleteObjects(OBJ_VERTICES, list);
+    MadeChanges = 1;
+    MadeMapChanges = 1;
 }
 
 
@@ -149,15 +149,15 @@
    Returns a non-zero value if the screen needs to be redrawn.
 */
 
-bool AutoMergeVertices (SelPtr *list, int obj_type, char operation)
+bool AutoMergeVertices(SelPtr * list, int obj_type, char operation)
 {
-SelPtr ref, cur;
-bool   redraw;
-bool   flipped, mergedone, isldend;
-int    v, refv;
-int    ld, sd;
-int    oldnumld;
-confirm_t confirm_flag;
+    SelPtr ref, cur;
+    bool redraw;
+    bool flipped, mergedone, isldend;
+    int v, refv;
+    int ld, sd;
+    int oldnumld;
+    confirm_t confirm_flag;
 
 /* FIXME this is quick-and-dirty hack ! The right thing
    would be to :
@@ -165,127 +165,127 @@
    - if obj_type == OBJ_SECTORS or OBJ_LINEDEFS, select
      all the vertices used by those sectors/linedefs and
      proceed as usually. */
-if (obj_type != OBJ_VERTICES)
-   return false;
+    if (obj_type != OBJ_VERTICES)
+	return false;
 
-redraw = false;
-mergedone = false;
-isldend = false;
+    redraw = false;
+    mergedone = false;
+    isldend = false;
 
-if (operation == 'i')
-   confirm_flag = insert_vertex_merge_vertices;
-else
-   confirm_flag = YC_ASK_ONCE;
+    if (operation == 'i')
+	confirm_flag = insert_vertex_merge_vertices;
+    else
+	confirm_flag = YC_ASK_ONCE;
 
 /* first, check if two (or more) vertices should be merged */
-ref = *list;
-while (ref)
-   {
-   refv = ref->objnum;
-   ref = ref->next;
-   /* check if there is a vertex at the same position (same X and Y) */
-   for (v = 0; v < NumVertices; v++)
-      if (v != refv
-         && Vertices[refv].x == Vertices[v].x
-	 && Vertices[refv].y == Vertices[v].y)
-         {
-         char buf[81];
-	 redraw = true;
-         sprintf (buf, "Vertices %d and %d occupy the same position", refv, v);
-	 if (Confirm2 (-1, -1, &confirm_flag,
-            buf,
-	    "Do you want to merge them into one?"))
+    ref = *list;
+    while (ref)
+    {
+	refv = ref->objnum;
+	ref = ref->next;
+	/* check if there is a vertex at the same position (same X and Y) */
+	for (v = 0; v < NumVertices; v++)
+	    if (v != refv
+		&& Vertices[refv].x == Vertices[v].x
+		&& Vertices[refv].y == Vertices[v].y)
 	    {
-	    /* merge the two vertices */
-	    mergedone = true;
-	    cur = NULL;
-	    SelectObject (&cur, refv);
-	    SelectObject (&cur, v);
-	    MergeVertices (&cur);
-	    /* update the references in the selection list */
-	    for (cur = *list; cur; cur = cur->next)
-	       if (cur->objnum > refv)
-		  cur->objnum = cur->objnum - 1;
-	    if (v > refv)
-	       v--;
-	    /* the old vertex has been deleted */
-	    UnSelectObject (list, refv);
-	    /* select the new vertex instead */
-	    if (!IsSelected (*list, v))
-	       SelectObject (list, v);
-	    break;
+		char buf[81];
+		redraw = true;
+		sprintf(buf, "Vertices %d and %d occupy the same position",
+			refv, v);
+		if (Confirm2
+		    (-1, -1, &confirm_flag, buf,
+		     "Do you want to merge them into one?"))
+		{
+		    /* merge the two vertices */
+		    mergedone = true;
+		    cur = NULL;
+		    SelectObject(&cur, refv);
+		    SelectObject(&cur, v);
+		    MergeVertices(&cur);
+		    /* update the references in the selection list */
+		    for (cur = *list; cur; cur = cur->next)
+			if (cur->objnum > refv)
+			    cur->objnum = cur->objnum - 1;
+		    if (v > refv)
+			v--;
+		    /* the old vertex has been deleted */
+		    UnSelectObject(list, refv);
+		    /* select the new vertex instead */
+		    if (!IsSelected(*list, v))
+			SelectObject(list, v);
+		    break;
+		}
+		else
+		    return redraw;
 	    }
-	 else
-	    return redraw;
-         }
-   }
+    }
 
 /* Now, check if one or more vertices are on a linedef */
 //DisplayMessage  (-1, -1, "Checking vertices on a linedef");
 
 // Distance in map units that is equivalent to 4 pixels
-int tolerance = (int) (4 / Scale);
+    int tolerance = (int) (4 / Scale);
 
-if (operation == 'i')
-   confirm_flag = insert_vertex_split_linedef;
-else
-   confirm_flag = YC_ASK_ONCE;
-ref = *list;
-while (ref)
-   {
-   refv = ref->objnum;
-   ref = ref->next;
-   oldnumld = NumLineDefs;
-   //printf ("V%d %d\n", refv, NumLineDefs); // DEBUG;
-   /* check if this vertex is on a linedef */
-   for (ld = 0; ld < oldnumld; ld++)
-      {
-      if (LineDefs[ld].start == refv || LineDefs[ld].end == refv)
-         {
-	 /* one vertex had a linedef bound to it -- check it later */
-	 isldend = true;
-         }
-      else if (IsLineDefInside (ld, Vertices[refv].x - tolerance,
-				    Vertices[refv].y - tolerance, 
-				    Vertices[refv].x + tolerance,
-				    Vertices[refv].y + tolerance))
-         {
-         char buf[81];
-	 redraw = true;
-         sprintf (buf, "Vertex %d is on top of linedef %d", refv, ld);
-	 if (Confirm2 (-1, -1, &confirm_flag,
-            buf,
-            "Do you want to split the linedef there?"))
+    if (operation == 'i')
+	confirm_flag = insert_vertex_split_linedef;
+    else
+	confirm_flag = YC_ASK_ONCE;
+    ref = *list;
+    while (ref)
+    {
+	refv = ref->objnum;
+	ref = ref->next;
+	oldnumld = NumLineDefs;
+	//printf ("V%d %d\n", refv, NumLineDefs); // DEBUG;
+	/* check if this vertex is on a linedef */
+	for (ld = 0; ld < oldnumld; ld++)
+	{
+	    if (LineDefs[ld].start == refv || LineDefs[ld].end == refv)
+	    {
+		/* one vertex had a linedef bound to it -- check it later */
+		isldend = true;
+	    }
+	    else if (IsLineDefInside(ld, Vertices[refv].x - tolerance,
+				     Vertices[refv].y - tolerance,
+				     Vertices[refv].x + tolerance,
+				     Vertices[refv].y + tolerance))
 	    {
-	    /* split the linedef */
-	    mergedone = true;
-	    InsertObject (OBJ_LINEDEFS, ld, 0, 0);
-	    LineDefs[ld].end = refv;
-	    LineDefs[NumLineDefs - 1].start = refv;
-	    sd = LineDefs[ld].sidedef1;
-	    if (sd >= 0)
-	       {
-	       InsertObject (OBJ_SIDEDEFS, sd, 0, 0);
-	       LineDefs[NumLineDefs - 1].sidedef1 = NumSideDefs - 1;
-	       }
- 	    sd = LineDefs[ld].sidedef2;
-	    if (sd >= 0)
-	       {
-	       InsertObject (OBJ_SIDEDEFS, sd, 0, 0);
-	       LineDefs[NumLineDefs - 1].sidedef2 = NumSideDefs - 1;
-	       }
-	    MadeChanges = 1;
-	    MadeMapChanges = 1;
+		char buf[81];
+		redraw = true;
+		sprintf(buf, "Vertex %d is on top of linedef %d", refv, ld);
+		if (Confirm2(-1, -1, &confirm_flag,
+			     buf, "Do you want to split the linedef there?"))
+		{
+		    /* split the linedef */
+		    mergedone = true;
+		    InsertObject(OBJ_LINEDEFS, ld, 0, 0);
+		    LineDefs[ld].end = refv;
+		    LineDefs[NumLineDefs - 1].start = refv;
+		    sd = LineDefs[ld].sidedef1;
+		    if (sd >= 0)
+		    {
+			InsertObject(OBJ_SIDEDEFS, sd, 0, 0);
+			LineDefs[NumLineDefs - 1].sidedef1 = NumSideDefs - 1;
+		    }
+		    sd = LineDefs[ld].sidedef2;
+		    if (sd >= 0)
+		    {
+			InsertObject(OBJ_SIDEDEFS, sd, 0, 0);
+			LineDefs[NumLineDefs - 1].sidedef2 = NumSideDefs - 1;
+		    }
+		    MadeChanges = 1;
+		    MadeMapChanges = 1;
+		}
+		else
+		    return redraw;
 	    }
-	 else
-	    return redraw;
-         }
-      }
-   }
+	}
+    }
 
 /* Don't continue if this isn't necessary */
-if (! isldend || ! mergedone)
-   return redraw;
+    if (!isldend || !mergedone)
+	return redraw;
 
 /* finally, test if two linedefs are between the same pair of vertices */
 /* AYM 1997-07-17
@@ -306,101 +306,103 @@
    before. */
 
 //DisplayMessage (-1, -1, "Checking superimposed linedefs");
-confirm_flag = YC_ASK_ONCE;
-{
-linedef_t *linedefs;
+    confirm_flag = YC_ASK_ONCE;
+    {
+	linedef_t *linedefs;
 
 /* Copy the linedefs into array 'linedefs' and sort it */
-linedefs = (linedef_t *) GetMemory (NumLineDefs * sizeof (linedef_t));
-for (ld = 0; ld < NumLineDefs; ld++)
-  {
-  linedefs[ld].vertexl = y_min (LineDefs[ld].start, LineDefs[ld].end);
-  linedefs[ld].vertexh = y_max (LineDefs[ld].start, LineDefs[ld].end);
-  linedefs[ld].linedefno = ld;
-  }
-qsort (linedefs, NumLineDefs, sizeof (linedef_t), SortLinedefs);
+	linedefs = (linedef_t *) GetMemory(NumLineDefs * sizeof(linedef_t));
+	for (ld = 0; ld < NumLineDefs; ld++)
+	{
+	    linedefs[ld].vertexl =
+		y_min(LineDefs[ld].start, LineDefs[ld].end);
+	    linedefs[ld].vertexh =
+		y_max(LineDefs[ld].start, LineDefs[ld].end);
+	    linedefs[ld].linedefno = ld;
+	}
+	qsort(linedefs, NumLineDefs, sizeof(linedef_t), SortLinedefs);
 
 /* Search for superimposed linedefs in the array */
-for (ld = 0; ld+1 < NumLineDefs; ld++)
-   {
-   if (linedefs[ld+1].vertexl != linedefs[ld].vertexl
-    || linedefs[ld+1].vertexh != linedefs[ld].vertexh)
-     continue;
-   int ld1 = linedefs[ld].linedefno;
-   int ld2 = linedefs[ld+1].linedefno;
-   char prompt[81];
-   y_snprintf (prompt, sizeof prompt, "Linedefs %d and %d are superimposed",
-      ld1, ld2);
-   redraw = true;
-   if (Expert || Confirm2 (-1, -1, &confirm_flag,
-      prompt, "(and perhaps others too). Merge them ?"))
-      {
-      LDPtr ldo = LineDefs + ld1;
-      LDPtr ldn = LineDefs + ld2;
-      /* Test if the linedefs have the same orientation */
-      if (ldn->start == ldo->end)
-	 flipped = true;
-      else
-	 flipped = false;
-      /* Merge linedef ldo (ld) into linedef ldn (ld+1) */
-      /* FIXME When is this done ? Most of the time when adding a
-	 door/corridor/window between two rooms, right ? So we should
-	 handle this in a smarter way by copying middle texture into
-	 lower and upper texture if the sectors don't have the same
-	 heights and maybe setting the LTU and UTU flags.
-	 This also applies when a linedef becomes two-sided as a
-	 result of creating a new sector. */
-      if (ldn->sidedef1 < 0)
-	 {
-	 if (flipped)
+	for (ld = 0; ld + 1 < NumLineDefs; ld++)
+	{
+	    if (linedefs[ld + 1].vertexl != linedefs[ld].vertexl
+		|| linedefs[ld + 1].vertexh != linedefs[ld].vertexh)
+		continue;
+	    int ld1 = linedefs[ld].linedefno;
+	    int ld2 = linedefs[ld + 1].linedefno;
+	    char prompt[81];
+	    y_snprintf(prompt, sizeof prompt,
+		       "Linedefs %d and %d are superimposed", ld1, ld2);
+	    redraw = true;
+	    if (Expert || Confirm2(-1, -1, &confirm_flag,
+				   prompt,
+				   "(and perhaps others too). Merge them ?"))
 	    {
-	    ldn->sidedef1 = ldo->sidedef2;
-	    ldo->sidedef2 = OBJ_NO_NONE;
-	    }
-	 else
-	    {
-	    ldn->sidedef1 = ldo->sidedef1;
-	    ldo->sidedef1 = OBJ_NO_NONE;
-	    }
-	 }
-      if (ldn->sidedef2 < 0)
-         {
-	 if (flipped)
-	    {
-	    ldn->sidedef2 = ldo->sidedef1;
-	    ldo->sidedef1 = OBJ_NO_NONE;
+		LDPtr ldo = LineDefs + ld1;
+		LDPtr ldn = LineDefs + ld2;
+		/* Test if the linedefs have the same orientation */
+		if (ldn->start == ldo->end)
+		    flipped = true;
+		else
+		    flipped = false;
+		/* Merge linedef ldo (ld) into linedef ldn (ld+1) */
+		/* FIXME When is this done ? Most of the time when adding a
+		   door/corridor/window between two rooms, right ? So we should
+		   handle this in a smarter way by copying middle texture into
+		   lower and upper texture if the sectors don't have the same
+		   heights and maybe setting the LTU and UTU flags.
+		   This also applies when a linedef becomes two-sided as a
+		   result of creating a new sector. */
+		if (ldn->sidedef1 < 0)
+		{
+		    if (flipped)
+		    {
+			ldn->sidedef1 = ldo->sidedef2;
+			ldo->sidedef2 = OBJ_NO_NONE;
+		    }
+		    else
+		    {
+			ldn->sidedef1 = ldo->sidedef1;
+			ldo->sidedef1 = OBJ_NO_NONE;
+		    }
+		}
+		if (ldn->sidedef2 < 0)
+		{
+		    if (flipped)
+		    {
+			ldn->sidedef2 = ldo->sidedef1;
+			ldo->sidedef1 = OBJ_NO_NONE;
+		    }
+		    else
+		    {
+			ldn->sidedef2 = ldo->sidedef2;
+			ldo->sidedef2 = OBJ_NO_NONE;
+		    }
+		}
+		if (ldn->sidedef1 >= 0 && ldn->sidedef2 >= 0
+		    && (ldn->flags & 0x04) == 0)
+		    ldn->flags = 0x04;
+		DeleteObject(Objid(OBJ_LINEDEFS, ld1));
 	    }
-	 else
-	    {
-	    ldn->sidedef2 = ldo->sidedef2;
-	    ldo->sidedef2 = OBJ_NO_NONE;
-	    }
-         }
-      if (ldn->sidedef1 >= 0 && ldn->sidedef2 >= 0 && (ldn->flags & 0x04) == 0)
-	 ldn->flags = 0x04;
-      DeleteObject (Objid (OBJ_LINEDEFS, ld1));
-      }
-   }
+	}
 
-FreeMemory (linedefs);
-}
+	FreeMemory(linedefs);
+    }
 
-return redraw;
+    return redraw;
 }
 
 
 /*
    compare two linedefs for sorting by lowest numbered vertex
 */
-static int SortLinedefs (const void *item1, const void *item2)
+static int SortLinedefs(const void *item1, const void *item2)
 {
 #define ld1 ((const linedef_t *) item1)
 #define ld2 ((const linedef_t *) item2)
-if (ld1->vertexl != ld2->vertexl)
-  return ld1->vertexl - ld2->vertexl;
-if (ld1->vertexh != ld2->vertexh)
-  return ld1->vertexh - ld2->vertexh;
-return 0;
+    if (ld1->vertexl != ld2->vertexl)
+	return ld1->vertexl - ld2->vertexl;
+    if (ld1->vertexh != ld2->vertexh)
+	return ld1->vertexh - ld2->vertexh;
+    return 0;
 }
-
-
--- a/src/v_polyg.cc	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/v_polyg.cc	Sat Sep 24 14:16:04 2011 +0300
@@ -37,18 +37,17 @@
    insert the vertices of a new polygon
 */
 
-void InsertPolygonVertices (int centerx, int centery, int sides, int radius)
+void InsertPolygonVertices(int centerx, int centery, int sides, int radius)
 {
-int n;
+    int n;
 
-for (n = 0; n < sides; n++)
-  InsertObject (OBJ_VERTICES, -1,
-    centerx
-    + (int) ((double)radius * cos (TWOPI * (double)n / (double)sides)),
-    centery
-    + (int) ((double)radius * sin (TWOPI * (double)n / (double)sides)));
+    for (n = 0; n < sides; n++)
+	InsertObject(OBJ_VERTICES, -1,
+		     centerx
+		     +
+		     (int) ((double) radius *
+			    cos(TWOPI * (double) n / (double) sides)),
+		     centery +
+		     (int) ((double) radius *
+			    sin(TWOPI * (double) n / (double) sides)));
 }
-
-
-
-
--- a/src/vectext.cc	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/vectext.cc	Sat Sep 24 14:16:04 2011 +0300
@@ -33,250 +33,273 @@
 #include "vectext.h"
 
 
-static const signed char vmin[] =
-{
-  16, 
-  'M',   0,  20, 
-  'd',  16,   0, 
+static const signed char vmin[] = {
+    16,
+    'M', 0, 20,
+    'd', 16, 0,
 };
 
-static const signed char v0[] =
-{
-  24, 
-  'M',   8,   0, 
-  'd',   8,   0, 
-  'd',   8,  12, 
-  'd',   0,  24, 
-  'd',  -8,  12, 
-  'd',  -8,   0, 
-  'd',  -8, -12, 
-  'd',   0, -24, 
-  'd',   8, -12, 
+static const signed char v0[] = {
+    24,
+    'M', 8, 0,
+    'd', 8, 0,
+    'd', 8, 12,
+    'd', 0, 24,
+    'd', -8, 12,
+    'd', -8, 0,
+    'd', -8, -12,
+    'd', 0, -24,
+    'd', 8, -12,
 };
 
-static const signed char v1[] =
-{
-  12, 
-  'M',   0,   8, 
-  'd',   8,  -8, 
-  'd',   0,  49, 
+static const signed char v1[] = {
+    12,
+    'M', 0, 8,
+    'd', 8, -8,
+    'd', 0, 49,
 };
 
-static const signed char v2[] =
-{
-  26, 
-  'M',   0,   4, 
-  'd',   8,  -4, 
-  'd',   8,   0, 
-  'd',   8,   8, 
-  'd',   0,   8, 
-  'd', -24,  32, 
-  'd',  26,   0, 
+static const signed char v2[] = {
+    26,
+    'M', 0, 4,
+    'd', 8, -4,
+    'd', 8, 0,
+    'd', 8, 8,
+    'd', 0, 8,
+    'd', -24, 32,
+    'd', 26, 0,
 };
 
-static const signed char v3[] =
-{
-  24, 
-  'M',   0,   4, 
-  'd',   8,  -4, 
-  'd',   8,   0, 
-  'd',   8,   8, 
-  'd',   0,   8, 
-  'd',  -8,   8,
-  'm',  -8,   0, 
-  'd',   8,   0, 
-  'd',   8,   8, 
-  'd',   0,   8, 
-  'd',  -8,   8, 
-  'd',  -8,   0, 
-  'd',  -8,  -4, 
+static const signed char v3[] = {
+    24,
+    'M', 0, 4,
+    'd', 8, -4,
+    'd', 8, 0,
+    'd', 8, 8,
+    'd', 0, 8,
+    'd', -8, 8,
+    'm', -8, 0,
+    'd', 8, 0,
+    'd', 8, 8,
+    'd', 0, 8,
+    'd', -8, 8,
+    'd', -8, 0,
+    'd', -8, -4,
 };
 
-static const signed char v4[] =
-{
-  24, 
-  'M',  24,  32, 
-  'd', -24,   0, 
-  'd',  20, -32, 
-  'd',   0,  48, 
+static const signed char v4[] = {
+    24,
+    'M', 24, 32,
+    'd', -24, 0,
+    'd', 20, -32,
+    'd', 0, 48,
 };
 
-static const signed char v5[] =
-{
-  28, 
-  'M',  28,   0, 
-  'd', -24,   0, 
-  'd',  -4,  20, 
-  'd',  20,   0, 
-  'd',   8,   8, 
-  'd',   0,  12, 
-  'd',  -8,   8, 
-  'd', -12,   0, 
-  'd',  -8,  -4, 
+static const signed char v5[] = {
+    28,
+    'M', 28, 0,
+    'd', -24, 0,
+    'd', -4, 20,
+    'd', 20, 0,
+    'd', 8, 8,
+    'd', 0, 12,
+    'd', -8, 8,
+    'd', -12, 0,
+    'd', -8, -4,
 };
 
-static const signed char v6[] =
-{
-  28, 
-  'M',  24,   0, 
-  'd', -16,   0, 
-  'd',  -8,  12, 
-  'd',   0,  24, 
-  'd',   8,  12, 
-  'd',  12,   0, 
-  'd',   8,  -8, 
-  'd',   0,  -8, 
-  'd',  -8,  -8, 
-  'd', -20,   0, 
+static const signed char v6[] = {
+    28,
+    'M', 24, 0,
+    'd', -16, 0,
+    'd', -8, 12,
+    'd', 0, 24,
+    'd', 8, 12,
+    'd', 12, 0,
+    'd', 8, -8,
+    'd', 0, -8,
+    'd', -8, -8,
+    'd', -20, 0,
 };
 
-static const signed char v7[] =
-{
-  24, 
-  'M',   0,   0, 
-  'd',  24,   0, 
-  'd', -20,  49, 
+static const signed char v7[] = {
+    24,
+    'M', 0, 0,
+    'd', 24, 0,
+    'd', -20, 49,
 };
 
-static const signed char v8[] =
-{
-  28, 
-  'M',   8,  24, 
-  'd',  -8,  -6, 
-  'd',   0, -12, 
-  'd',   8,  -6, 
-  'd',  12,   0, 
-  'd',   8,   6, 
-  'd',   0,  12, 
-  'd',  -8,   6, 
-  'd', -12,   0, 
-  'd',  -8,   6,
-  'd',   0,  12, 
-  'd',   8,   6, 
-  'd',  12,   0, 
-  'd',   8,  -6, 
-  'd',   0, -12, 
-  'd',  -8,  -6, 
+static const signed char v8[] = {
+    28,
+    'M', 8, 24,
+    'd', -8, -6,
+    'd', 0, -12,
+    'd', 8, -6,
+    'd', 12, 0,
+    'd', 8, 6,
+    'd', 0, 12,
+    'd', -8, 6,
+    'd', -12, 0,
+    'd', -8, 6,
+    'd', 0, 12,
+    'd', 8, 6,
+    'd', 12, 0,
+    'd', 8, -6,
+    'd', 0, -12,
+    'd', -8, -6,
 };
 
-static const signed char v9[] =
-{
-  28, 
-  'M',  28,  24, 
-  'd', -20,   0, 
-  'd',  -8,  -8, 
-  'd',   0,  -8, 
-  'd',   8,  -8, 
-  'd',  12,   0, 
-  'd',   8,  12, 
-  'd',   0,  24, 
-  'd',  -8,  12, 
-  'd', -16,   0, 
+static const signed char v9[] = {
+    28,
+    'M', 28, 24,
+    'd', -20, 0,
+    'd', -8, -8,
+    'd', 0, -8,
+    'd', 8, -8,
+    'd', 12, 0,
+    'd', 8, 12,
+    'd', 0, 24,
+    'd', -8, 12,
+    'd', -16, 0,
 };
 
 
 
-static inline void vdata (char c, const signed char *& p, size_t& s)
+static inline void vdata(char c, const signed char *&p, size_t & s)
 {
-  switch (c)
-  {
-    case '-': p = vmin; s = sizeof vmin; break;
-    case '0': p = v0;   s = sizeof v0;   break;
-    case '1': p = v1;   s = sizeof v1;   break;
-    case '2': p = v2;   s = sizeof v2;   break;
-    case '3': p = v3;   s = sizeof v3;   break;
-    case '4': p = v4;   s = sizeof v4;   break;
-    case '5': p = v5;   s = sizeof v5;   break;
-    case '6': p = v6;   s = sizeof v6;   break;
-    case '7': p = v7;   s = sizeof v7;   break;
-    case '8': p = v8;   s = sizeof v8;   break;
-    case '9': p = v9;   s = sizeof v9;   break;
-    default:  p = 0;    s = 0;           break;
-  }
+    switch (c)
+    {
+    case '-':
+	p = vmin;
+	s = sizeof vmin;
+	break;
+    case '0':
+	p = v0;
+	s = sizeof v0;
+	break;
+    case '1':
+	p = v1;
+	s = sizeof v1;
+	break;
+    case '2':
+	p = v2;
+	s = sizeof v2;
+	break;
+    case '3':
+	p = v3;
+	s = sizeof v3;
+	break;
+    case '4':
+	p = v4;
+	s = sizeof v4;
+	break;
+    case '5':
+	p = v5;
+	s = sizeof v5;
+	break;
+    case '6':
+	p = v6;
+	s = sizeof v6;
+	break;
+    case '7':
+	p = v7;
+	s = sizeof v7;
+	break;
+    case '8':
+	p = v8;
+	s = sizeof v8;
+	break;
+    case '9':
+	p = v9;
+	s = sizeof v9;
+	break;
+    default:
+	p = 0;
+	s = 0;
+	break;
+    }
 }
 
 
-static inline int vwidth (char c)
+static inline int vwidth(char c)
 {
-  const signed char *d;
-  size_t s;
-  vdata (c, d, s);
-  if (d == 0)
-    return 0;
-  return *d;
-}
-
-
-void draw_vint (int number, int x, int y, double scale)
-{
-  char buf[20];
-  y_snprintf (buf, sizeof buf, "%d", number);
-  draw_vstring (buf, x, y, scale);
+    const signed char *d;
+    size_t s;
+    vdata(c, d, s);
+    if (d == 0)
+	return 0;
+    return *d;
 }
 
 
-void draw_vstring (const char *string, int x, int y, double scale)
+void draw_vint(int number, int x, int y, double scale)
 {
-  const int    height = 48;		// Height in units FIXME hard-coded
-  const double ppu    = scale / 4;	// Pixels per unit
-
-  // Calculate in advance the whole width of the text
-  int width = 0;			// Width in units
-  for (const char *s = string; *s; s++)
-    width += vwidth (*s);
-  
-  int xref = (int) (x - width  * ppu / 2);
-  int yref = (int) (y - height * ppu / 2);
-  for (const char *s = string; *s; s++)
-  {
-    int xcur = xref;
-    int ycur = yref;
-    const signed char *d, *dend;
-    size_t size;
-    vdata (*s, d, size);
-    if (d == 0 || size < 1)
-      continue;
-    dend = d + size;
-
-    // Extract the width;
-    int w = *d++;
-
-    // Process the statements
-    while ((d + 2) < dend)
-    {
-      if (*d == 'd')  // d - draw to relative position
-      {
-	d++;
-	int xofs = *d++;
-	int yofs = *d++;
-	DrawScreenLine (
-	   (int) (xref + xcur          * ppu + 0.5),
-	   (int) (yref + ycur          * ppu + 0.5),
-	   (int) (xref + (xcur + xofs) * ppu + 0.5),
-	   (int) (yref + (ycur + yofs) * ppu + 0.5));
-	xcur += xofs;
-	ycur += yofs;
-      }
-      else if (*d == 'm')  // m - move the cursor to relative position
-      {
-	d++;
-	xcur += *d++;
-	ycur += *d++;
-      }
-      else if (*d == 'M')  // M - move the cursor to absolute position
-      {
-	d++;
-	xcur = *d++;
-	ycur = *d++;
-      }
-      else
-      {
-	nf_bug ("bad statement \"%c\"", *d);
-	d += 3;
-	continue;
-      }
-    }
-    xref += (int) ((w + 8) * ppu + 0.5);
-  }
+    char buf[20];
+    y_snprintf(buf, sizeof buf, "%d", number);
+    draw_vstring(buf, x, y, scale);
 }
 
+
+void draw_vstring(const char *string, int x, int y, double scale)
+{
+    const int height = 48;	// Height in units FIXME hard-coded
+    const double ppu = scale / 4;	// Pixels per unit
+
+    // Calculate in advance the whole width of the text
+    int width = 0;		// Width in units
+    for (const char *s = string; *s; s++)
+	width += vwidth(*s);
+
+    int xref = (int) (x - width * ppu / 2);
+    int yref = (int) (y - height * ppu / 2);
+    for (const char *s = string; *s; s++)
+    {
+	int xcur = xref;
+	int ycur = yref;
+	const signed char *d, *dend;
+	size_t size;
+	vdata(*s, d, size);
+	if (d == 0 || size < 1)
+	    continue;
+	dend = d + size;
+
+	// Extract the width;
+	int w = *d++;
+
+	// Process the statements
+	while ((d + 2) < dend)
+	{
+	    if (*d == 'd')	// d - draw to relative position
+	    {
+		d++;
+		int xofs = *d++;
+		int yofs = *d++;
+		DrawScreenLine((int) (xref + xcur * ppu + 0.5),
+			       (int) (yref + ycur * ppu + 0.5),
+			       (int) (xref + (xcur + xofs) * ppu + 0.5),
+			       (int) (yref + (ycur + yofs) * ppu + 0.5));
+		xcur += xofs;
+		ycur += yofs;
+	    }
+	    else if (*d == 'm')	// m - move the cursor to relative position
+	    {
+		d++;
+		xcur += *d++;
+		ycur += *d++;
+	    }
+	    else if (*d == 'M')	// M - move the cursor to absolute position
+	    {
+		d++;
+		xcur = *d++;
+		ycur = *d++;
+	    }
+	    else
+	    {
+		nf_bug("bad statement \"%c\"", *d);
+		d += 3;
+		continue;
+	    }
+	}
+	xref += (int) ((w + 8) * ppu + 0.5);
+    }
+}
--- a/src/vectext.h	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/vectext.h	Sat Sep 24 14:16:04 2011 +0300
@@ -4,6 +4,5 @@
  */
 
 
-void draw_vint    (int         number, int x, int y, double scale);
-void draw_vstring (const char *string, int x, int y, double scale);
-
+void draw_vint(int number, int x, int y, double scale);
+void draw_vstring(const char *string, int x, int y, double scale);
--- a/src/verbmsg.cc	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/verbmsg.cc	Sat Sep 24 14:16:04 2011 +0300
@@ -34,14 +34,12 @@
  *	verbmsg
  *	Like printf() but does nothing unlike <verbose> is set.
  */
-void verbmsg (const char *fmt, ...)
+void verbmsg(const char *fmt, ...)
 {
-va_list args;
+    va_list args;
 
-if (! verbose)
-   return;
-va_start (args, fmt);
-vprintf (fmt, args);
+    if (!verbose)
+	return;
+    va_start(args, fmt);
+    vprintf(fmt, args);
 }
-
-
--- a/src/wadfile.cc	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/wadfile.cc	Sat Sep 24 14:16:04 2011 +0300
@@ -34,23 +34,23 @@
 /*
  *	Wad_file::~Wad_file - dtor
  */
-Wad_file::~Wad_file ()
+Wad_file::~Wad_file()
 {
-  if (directory != 0)
-  {
-    FreeMemory (directory);
-    directory = 0;			// Catch bugs
-  }
-  if (fp != 0)
-  {
-    fclose (fp);
-    fp = 0;				// Catch bugs
-  }
-  if (filename != 0)
-  {
-    FreeMemory (filename);
-    filename = 0;			// Catch bugs
-  }
+    if (directory != 0)
+    {
+	FreeMemory(directory);
+	directory = 0;		// Catch bugs
+    }
+    if (fp != 0)
+    {
+	fclose(fp);
+	fp = 0;			// Catch bugs
+    }
+    if (filename != 0)
+    {
+	FreeMemory(filename);
+	filename = 0;		// Catch bugs
+    }
 }
 
 
@@ -59,28 +59,25 @@
  *
  *	Return pointer to a per-Wad_file buffer.
  */
-const char *Wad_file::where () const
+const char *Wad_file::where() const
 {
-  const unsigned long offset       = ftell (fp);
-  const size_t        offset_len   =  + 3;
-  const size_t        name_len_max = sizeof where_ - 1 - offset_len;
+    const unsigned long offset = ftell(fp);
+    const size_t offset_len = +3;
+    const size_t name_len_max = sizeof where_ - 1 - offset_len;
 
-  if (name_len_max >= strlen (filename)) 
-    sprintf (where_, "%s(%lXh)", filename, offset);
-  else
-  {
-    const char  *ellipsis = "...";
-    const size_t total    = name_len_max - strlen (ellipsis);
-    const size_t left     = total / 2;
-    const size_t right    = total - left;
-    sprintf (where_, "%*s%s%*s(%lXh)",
-	left, filename,
-	ellipsis,
-	right, filename + total,
-	offset);
-  }
+    if (name_len_max >= strlen(filename))
+	sprintf(where_, "%s(%lXh)", filename, offset);
+    else
+    {
+	const char *ellipsis = "...";
+	const size_t total = name_len_max - strlen(ellipsis);
+	const size_t left = total / 2;
+	const size_t right = total - left;
+	sprintf(where_, "%*s%s%*s(%lXh)",
+		left, filename, ellipsis, right, filename + total, offset);
+    }
 
-  return where_;
+    return where_;
 }
 
 
@@ -94,32 +91,30 @@
  *
  *	Return the number of bytes read.
  */
-long Wad_file::read_vbytes (void *buf, long count) const
+long Wad_file::read_vbytes(void *buf, long count) const
 {
-  long bytes_read_total;
-  size_t bytes_read;
-  size_t bytes_to_read;
+    long bytes_read_total;
+    size_t bytes_read;
+    size_t bytes_to_read;
 
-  bytes_read_total = 0;
-  bytes_to_read    = 0x8000;
-  while (count > 0)
-  {
-    if (count <= 0x8000)
-      bytes_to_read = (size_t) count;
-    bytes_read = fread (buf, 1, bytes_to_read, fp);
-    bytes_read_total += bytes_read;
-    if (bytes_read != bytes_to_read)
-      break;
-    buf = (char *) buf + bytes_read;
-    count -= bytes_read;
-  }
-  if (ferror (fp))
-  {
-    if (! error_)
-      err ("%s: read error", where ());
-    error_ = true;
-  }
-  return bytes_read_total;
+    bytes_read_total = 0;
+    bytes_to_read = 0x8000;
+    while (count > 0)
+    {
+	if (count <= 0x8000)
+	    bytes_to_read = (size_t) count;
+	bytes_read = fread(buf, 1, bytes_to_read, fp);
+	bytes_read_total += bytes_read;
+	if (bytes_read != bytes_to_read)
+	    break;
+	buf = (char *) buf + bytes_read;
+	count -= bytes_read;
+    }
+    if (ferror(fp))
+    {
+	if (!error_)
+	    err("%s: read error", where());
+	error_ = true;
+    }
+    return bytes_read_total;
 }
-
-
--- a/src/wadfile.h	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/wadfile.h	Sat Sep 24 14:16:04 2011 +0300
@@ -27,7 +27,7 @@
 */
 
 
-#ifndef YH_WADFILE  /* DO NOT INSERT ANYTHING BEFORE THIS LINE */
+#ifndef YH_WADFILE		/* DO NOT INSERT ANYTHING BEFORE THIS LINE */
 #define YH_WADFILE
 
 
@@ -86,78 +86,73 @@
  */
 class Wad_file
 {
-  /* Ugly but better than making the data members public. FIXME
-     Many of these are friend just because they use fp for
-     reading. */
-  friend char     *GetWadFileName     (const char *);
-  friend int       SaveLevelData      (const char *, const char *);
-  friend int       OpenMainWad        (const char *);
-  friend int       OpenPatchWad       (const char *);
-  friend Wad_file *BasicWadOpen       (const char *, ygpf_t);
-  friend void      BuildNewMainWad    (const char *, bool);
-  friend void      SaveDirectoryEntry (FILE *, const char *);
-  friend void      SaveEntryToRawFile (FILE *, const char *);
-  friend void      ListFileDirectory  (FILE *, const Wad_file *);
+    /* Ugly but better than making the data members public. FIXME
+       Many of these are friend just because they use fp for
+       reading. */
+    friend char *GetWadFileName(const char *);
+    friend int SaveLevelData(const char *, const char *);
+    friend int OpenMainWad(const char *);
+    friend int OpenPatchWad(const char *);
+    friend Wad_file *BasicWadOpen(const char *, ygpf_t);
+    friend void BuildNewMainWad(const char *, bool);
+    friend void SaveDirectoryEntry(FILE *, const char *);
+    friend void SaveEntryToRawFile(FILE *, const char *);
+    friend void ListFileDirectory(FILE *, const Wad_file *);
 
-  public :
-    Wad_file () :
-      filename (0),
-      pic_format_ (YGPF_NORMAL),
-      fp (0),
-      dirsize (0),
-      dirstart (0),
-      directory (0),
-      error_ (false)
+    public:Wad_file():filename(0), pic_format_(YGPF_NORMAL),
+                      fp(0), dirsize(0), dirstart(0),
+                      directory(0), error_(false)
     {
-      strcpy (type, "BUG");
-      strcpy (where_, "DEADBEEF");
+	strcpy(type, "BUG");
+	strcpy(where_, "DEADBEEF");
     }
-    ~Wad_file ();
-    const char *pathname    () const;
-    ygpf_t      pic_format  () const;
-    bool        error       () const;
-    const char *where       () const;
-    void        seek        (long offset) const;
-    u8          read_u8     () const;
-    void        read_u8     (u8& buf) const;
-    i16         read_i16    () const;
-    void        read_i16    (i16 *buf) const;
-    void        read_i32    (i32 *buf, long count = 1) const;
-    void        read_bytes  (void *buf, long count) const;
-    long        read_vbytes (void *buf, long count) const;
-    const char *what        () const;
 
-  private :
-    char *filename;			// Name of the wad file
-    ygpf_t pic_format_;			// Picture format (usually PF_NORMAL)
-    FILE *fp;				// C file stream information
-    char type[4];			// Type of wad file ("IWAD" or "PWAD")
-    i32  dirsize;			// Entries in directory
-    i32  dirstart;			// Offset to start of directory
-    DirPtr directory;			// Array of directory information
-    mutable bool error_;		// I/O error occur since last error()
-    mutable char where_[101];		// Static workspace for where()
+    ~Wad_file();
+    const char *pathname() const;
+    ygpf_t pic_format() const;
+    bool error() const;
+    const char *where() const;
+    void seek(long offset) const;
+    u8 read_u8() const;
+    void read_u8(u8 & buf) const;
+    i16 read_i16() const;
+    void read_i16(i16 * buf) const;
+    void read_i32(i32 * buf, long count = 1) const;
+    void read_bytes(void *buf, long count) const;
+    long read_vbytes(void *buf, long count) const;
+    const char *what() const;
 
-    Wad_file (const Wad_file& rhs);		// Deliberately not implemented
-    Wad_file& operator= (const Wad_file& rhs);	// Deliberately not implemented
+  private:
+    char *filename;		// Name of the wad file
+    ygpf_t pic_format_;		// Picture format (usually PF_NORMAL)
+    FILE *fp;			// C file stream information
+    char type[4];		// Type of wad file ("IWAD" or "PWAD")
+    i32 dirsize;		// Entries in directory
+    i32 dirstart;		// Offset to start of directory
+    DirPtr directory;		// Array of directory information
+    mutable bool error_;	// I/O error occur since last error()
+    mutable char where_[101];	// Static workspace for where()
+
+    Wad_file(const Wad_file & rhs);	// Deliberately not implemented
+    Wad_file & operator=(const Wad_file & rhs);	// Deliberately not implemented
 };
 
 
 /*
  *	Wad_file::pathname - return the pathname of the file
  */
-inline const char *Wad_file::pathname () const
+inline const char *Wad_file::pathname() const
 {
-  return filename;
+    return filename;
 }
 
 
 /*
  *	Wad_file::pic_format - return the pic_format of the wad
  */
-inline ygpf_t Wad_file::pic_format () const
+inline ygpf_t Wad_file::pic_format() const
 {
-  return pic_format_;
+    return pic_format_;
 }
 
 
@@ -174,14 +169,14 @@
  *
  *	Return true if an error occurred, false otherwise.
  */
-inline bool Wad_file::error () const
+inline bool Wad_file::error() const
 {
-  if (! error_)
-    return false;
+    if (!error_)
+	return false;
 
-  clearerr (fp);
-  error_ = false;
-  return true;
+    clearerr(fp);
+    error_ = false;
+    return true;
 }
 
 
@@ -190,14 +185,14 @@
  *
  *	If an error occurs, set the error flag.
  */
-inline void Wad_file::seek (long offset) const
+inline void Wad_file::seek(long offset) const
 {
-  if (fseek (fp, offset, 0) != 0)
-  {
-    if (! error_)
-      err ("%s: can't seek to %lXh", filename, offset);
-    error_ = true;
-  }
+    if (fseek(fp, offset, 0) != 0)
+    {
+	if (!error_)
+	    err("%s: can't seek to %lXh", filename, offset);
+	error_ = true;
+    }
 }
 
 
@@ -207,17 +202,17 @@
  *	If an error occurs, set the error flag and the return
  *	value is undefined.
  */
-inline u8 Wad_file::read_u8 () const
+inline u8 Wad_file::read_u8() const
 {
-  u8 v = u8 (getc (fp));
+    u8 v = u8(getc(fp));
 
-  if (feof (fp) || ferror (fp))
-  {
-    if (! error_)
-      err ("%s: read error", where ());
-    error_ = true;
-  }
-  return v;
+    if (feof(fp) || ferror(fp))
+    {
+	if (!error_)
+	    err("%s: read error", where());
+	error_ = true;
+    }
+    return v;
 }
 
 
@@ -227,16 +222,16 @@
  *	If an error occurs, set the error flag and the contents
  *	of buf is undefined.
  */
-inline void Wad_file::read_u8 (u8& buf) const
+inline void Wad_file::read_u8(u8 & buf) const
 {
-  buf = getc (fp);
+    buf = getc(fp);
 
-  if (feof (fp) || ferror (fp))
-  {
-    if (! error_)
-      err ("%s: read error", where ());
-    error_ = true;
-  }
+    if (feof(fp) || ferror(fp))
+    {
+	if (!error_)
+	    err("%s: read error", where());
+	error_ = true;
+    }
 }
 
 
@@ -246,19 +241,19 @@
  *	If an error occurs, set the error flag and the return
  *	value is undefined.
  */
-inline i16 Wad_file::read_i16 () const
+inline i16 Wad_file::read_i16() const
 {
-  const size_t nbytes = 2;
-  u8 buf[nbytes];
+    const size_t nbytes = 2;
+    u8 buf[nbytes];
 
-  if (fread (buf, 1, nbytes, fp) != nbytes)
-  {
-    if (! error_)
-      err ("%s: read error", where ());
-    error_ = true;
-    return EOF;  // Whatever
-  }
-  return buf[0] | buf[1] << 8;
+    if (fread(buf, 1, nbytes, fp) != nbytes)
+    {
+	if (!error_)
+	    err("%s: read error", where());
+	error_ = true;
+	return EOF;		// Whatever
+    }
+    return buf[0] | buf[1] << 8;
 }
 
 
@@ -268,16 +263,16 @@
  *	The value read is stored in *buf. If an error occurs,
  *	set the error flag and the contents of *buf is undefined.
  */
-inline void Wad_file::read_i16 (i16 *buf) const
+inline void Wad_file::read_i16(i16 * buf) const
 {
-  *buf = getc (fp) | (getc (fp) << 8);
+    *buf = getc(fp) | (getc(fp) << 8);
 
-  if (feof (fp) || ferror (fp))
-  {
-    if (! error_)
-      err ("%s: read error", where ());
-    error_ = true;
-  }
+    if (feof(fp) || ferror(fp))
+    {
+	if (!error_)
+	    err("%s: read error", where());
+	error_ = true;
+    }
 }
 
 
@@ -288,22 +283,21 @@
  *	wad file <wadfile> into *buf. If an error occurs, set
  *	error_ and the contents of *buf is undefined.
  */
-inline void Wad_file::read_i32 (i32 *buf, long count) const
+inline void Wad_file::read_i32(i32 * buf, long count) const
 {
-  while (count-- > 0)
-  {
-    *buf++ =    getc (fp)
-       | (      getc (fp) << 8)
-       | ((i32) getc (fp) << 16)
-       | ((i32) getc (fp) << 24);
-  }
+    while (count-- > 0)
+    {
+	*buf++ = getc(fp)
+	    | (getc(fp) << 8)
+	    | ((i32) getc(fp) << 16) | ((i32) getc(fp) << 24);
+    }
 
-  if (feof (fp) || ferror (fp))
-  {
-    if (! error_)
-      err ("%s: read error", where ());
-    error_ = true;
-  }
+    if (feof(fp) || ferror(fp))
+    {
+	if (!error_)
+	    err("%s: read error", where());
+	error_ = true;
+    }
 }
 
 
@@ -315,17 +309,17 @@
  *	occurs or EOF is reached before the requested number of
  *	bytes is read, set the error flag.
  */
-inline void Wad_file::read_bytes (void *buf, long count) const
+inline void Wad_file::read_bytes(void *buf, long count) const
 {
-  long bytes_read;
+    long bytes_read;
 
-  bytes_read = read_vbytes (buf, count);
-  if (bytes_read != count)
-  {
-    if (! error_)
-      err ("%s: read error", where ());
-    error_ = true;
-  }
+    bytes_read = read_vbytes(buf, count);
+    if (bytes_read != count)
+    {
+	if (!error_)
+	    err("%s: read error", where());
+	error_ = true;
+    }
 }
 
 
@@ -336,14 +330,14 @@
  *	name of the first lump in the wad, which gives an idea
  *	of what it contains. The string is *not* NUL-terminated.
  */
-inline const char *Wad_file::what () const
+inline const char *Wad_file::what() const
 {
-  if (directory == 0)
-    return "(nodir)";
-  if (dirsize < 1)
-    return "(empty)";
-  return directory[0].name;
+    if (directory == 0)
+	return "(nodir)";
+    if (dirsize < 1)
+	return "(empty)";
+    return directory[0].name;
 }
 
 
-#endif  /* DO NOT ADD ANYTHING AFTER THIS LINE */
+#endif /* DO NOT ADD ANYTHING AFTER THIS LINE */
--- a/src/wadlist.cc	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/wadlist.cc	Sat Sep 24 14:16:04 2011 +0300
@@ -34,53 +34,52 @@
 #include <boost/smart_ptr.hpp>
 
 
-Wad_list wad_list;			// One global instance
+Wad_list wad_list;		// One global instance
 
 
-typedef std::list<boost::shared_ptr<Wad_file> > list_t;
+typedef std::list < boost::shared_ptr < Wad_file > >list_t;
 
 
 class Wad_list_priv
 {
-  public :
-    Wad_list_priv ();
+    public: Wad_list_priv();
     list_t list;
     mutable list_t::iterator iter;	// Current element
-    mutable bool rewound;		// If true, next get() will return head
+    mutable bool rewound;	// If true, next get() will return head
 };
 
 
-Wad_list_priv::Wad_list_priv ()
+Wad_list_priv::Wad_list_priv()
 {
-  rewound = true;
+    rewound = true;
 }
 
 
 /*
  *	Wad_list::Wad_list - default ctor
  */
-Wad_list::Wad_list ()
+Wad_list::Wad_list()
 {
-  priv = new Wad_list_priv;
+    priv = new Wad_list_priv;
 }
 
 
 /*
  *	Wad_list::~Wad_list - dtor
  */
-Wad_list::~Wad_list ()
+Wad_list::~Wad_list()
 {
-  delete priv;
-  priv = 0;				// Catch bugs
+    delete priv;
+    priv = 0;			// Catch bugs
 }
 
 
 /*
  *	Wad_list::rewind - arrange so that the next get() will return head
  */
-void Wad_list::rewind () const
+void Wad_list::rewind() const
 {
-  priv->rewound = true;
+    priv->rewound = true;
 }
 
 
@@ -95,51 +94,51 @@
  *	Return false if already at the end of the list, true
  *	otherwise.
  */
-bool Wad_list::get (Wad_file *& wf)
+bool Wad_list::get(Wad_file * &wf)
 {
-  if (priv->rewound)
-  {
-    priv->iter = priv->list.begin ();
-    priv->rewound = false;
-  }
-  else
-    ++priv->iter;
+    if (priv->rewound)
+    {
+	priv->iter = priv->list.begin();
+	priv->rewound = false;
+    }
+    else
+	++priv->iter;
 
-  if (priv->iter == priv->list.end ())
-  {
-    wf = 0;
-    return false;
-  }
+    if (priv->iter == priv->list.end())
+    {
+	wf = 0;
+	return false;
+    }
 
-  wf = priv->iter->get ();
-  return true;
+    wf = priv->iter->get();
+    return true;
 }
 
 
-bool Wad_list::get (const Wad_file *& wf) const
+bool Wad_list::get(const Wad_file * &wf) const
 {
-  if (priv->rewound)
-  {
-    priv->iter = priv->list.begin ();
-    priv->rewound = false;
-  }
-  else
-    ++priv->iter;
+    if (priv->rewound)
+    {
+	priv->iter = priv->list.begin();
+	priv->rewound = false;
+    }
+    else
+	++priv->iter;
 
-  if (priv->iter == priv->list.end ())
-    return false;
+    if (priv->iter == priv->list.end())
+	return false;
 
-  wf = priv->iter->get ();
-  return true;
+    wf = priv->iter->get();
+    return true;
 }
 
 
 /*
  *	Wad_list::insert - insert a new wad at the pointer
  */
-void Wad_list::insert (Wad_file *wf)
+void Wad_list::insert(Wad_file * wf)
 {
-  priv->list.insert (priv->iter, boost::shared_ptr<Wad_file> (wf));
+    priv->list.insert(priv->iter, boost::shared_ptr < Wad_file > (wf));
 }
 
 
@@ -155,28 +154,27 @@
  *
  *	If already at the end of the list, nf_bug() is called.
  */
-void Wad_list::del ()
+void Wad_list::del()
 {
-  list_t::iterator i;
+    list_t::iterator i;
 
-  if (priv->rewound)
-  {
-    i = priv->list.begin ();
-  }
-  else
-  {
-    i = priv->iter;
-  }
-  if (i == priv->list.end ())
-  {
-    nf_bug ("Wad_list::del: attempt to delete last item");
-    return;
-  }
-  priv->iter = priv->list.erase (i);
-  if (priv->iter == priv->list.begin ())
-  {
-//    priv->iter = 0;			// Catch bugs
-    priv->rewound = true;
-  }
+    if (priv->rewound)
+    {
+	i = priv->list.begin();
+    }
+    else
+    {
+	i = priv->iter;
+    }
+    if (i == priv->list.end())
+    {
+	nf_bug("Wad_list::del: attempt to delete last item");
+	return;
+    }
+    priv->iter = priv->list.erase(i);
+    if (priv->iter == priv->list.begin())
+    {
+//    priv->iter = 0;                   // Catch bugs
+	priv->rewound = true;
+    }
 }
-
--- a/src/wadlist.h	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/wadlist.h	Sat Sep 24 14:16:04 2011 +0300
@@ -27,7 +27,7 @@
 */
 
 
-#ifndef YH_WADLIST  /* DO NOT INSERT ANYTHING BEFORE THIS LINE */
+#ifndef YH_WADLIST		/* DO NOT INSERT ANYTHING BEFORE THIS LINE */
 #define YH_WADLIST
 
 
@@ -61,23 +61,21 @@
 
 class Wad_list
 {
-  public :
-    Wad_list    ();
-    ~Wad_list   ();
-    void rewind () const;
-    bool get    (const Wad_file *& wf) const;
-    bool get    (Wad_file *& wf);
-    void insert (Wad_file *);
-    void del    ();
+    public:Wad_list();
+    ~Wad_list();
+    void rewind() const;
+    bool get(const Wad_file * &wf) const;
+    bool get(Wad_file * &wf);
+    void insert(Wad_file *);
+    void del();
 
-  private :
-    Wad_list (const Wad_list&);			// Too lazy to implement it
-    Wad_list& operator= (const Wad_list&);	// Too lazy to implement it
+      private: Wad_list(const Wad_list &);	// Too lazy to implement it
+      Wad_list & operator=(const Wad_list &);	// Too lazy to implement it
     Wad_list_priv *priv;
 };
 
 
-extern Wad_list wad_list;		// One global instance
+extern Wad_list wad_list;	// One global instance
 
 
-#endif  /* DO NOT ADD ANYTHING AFTER THIS LINE */
+#endif /* DO NOT ADD ANYTHING AFTER THIS LINE */
--- a/src/wadname.h	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/wadname.h	Sat Sep 24 14:16:04 2011 +0300
@@ -31,7 +31,7 @@
 #define YH_WADNAME
 
 
-#include <memory.h>
+//#include <memory.h>
 #include <ctype.h>
 
 #include "wstructs.h"
@@ -53,15 +53,15 @@
  */
 struct Wad_name
 {
-  inline Wad_name ();
-  inline Wad_name (const Wad_name& source);
-  inline Wad_name (const char *source);
-  inline Wad_name& operator=  (const char *source);
-  inline bool      operator== (const Wad_name& ref) const;
-  inline bool      operator== (const char *ref) const;
-  inline bool      less       (const Wad_name& other) const;
-  inline bool      has_prefix (const Wad_name& prefix) const;
-  wad_name_t name;
+    inline Wad_name ();
+    inline Wad_name (const Wad_name& source);
+    inline Wad_name (const char *source);
+    inline Wad_name& operator=  (const char *source);
+    inline bool      operator== (const Wad_name& ref) const;
+    inline bool      operator== (const char *ref) const;
+    inline bool      less       (const Wad_name& other) const;
+    inline bool      has_prefix (const Wad_name& prefix) const;
+    wad_name_t name;
 };
 
 
@@ -70,7 +70,7 @@
  */
 inline Wad_name::Wad_name ()
 {
-  memset (name, '\0', sizeof name);
+    memset (name, 0, sizeof(name));
 }
 
 
@@ -80,10 +80,9 @@
  *	The source *must* be already upper-cased and padded with
  *	NULs.
  */
-
 inline Wad_name::Wad_name (const Wad_name& source)
 {
-  memcpy (name, source.name, sizeof name);
+    memcpy (name, source.name, sizeof name);
 }
 
 
@@ -92,13 +91,15 @@
  */
 inline Wad_name::Wad_name (const char *source)
 {
-  char *p;
-  char *const pmax = name + sizeof name;
-  for (p = name; *source != '\0' && p < pmax; p++)
-    *p = toupper (*source++);
-  // Pad with NULs to the end
-  for (; p < pmax; p++)
-    *p = '\0';
+    char *p;
+    char *const pmax = name + sizeof name;
+
+    for (p = name; *source != '\0' && p < pmax; p++)
+        *p = toupper (*source++);
+
+    // Pad with NULs to the end
+    for (; p < pmax; p++)
+        *p = '\0';
 }
 
 
@@ -123,7 +124,7 @@
  */
 inline bool Wad_name::operator== (const Wad_name& ref) const
 {
-  return this == &ref || ! memcmp (name, ref.name, sizeof name);
+    return this == &ref || ! memcmp (name, ref.name, sizeof name);
 }
 
 
@@ -132,7 +133,7 @@
  */
 inline bool Wad_name::operator== (const char *ref) const
 {
-  return ! y_strnicmp (name, ref, sizeof name);
+    return ! y_strnicmp (name, ref, sizeof name);
 }
 
 
@@ -147,19 +148,9 @@
  */
 inline bool Wad_name::less (const Wad_name& other) const
 {
-  const char *p1 = name;
-  const char *p2 = other.name;
-  if (*p1 < *p2) return true; if (*p1++ > *p2++) return false;
-  if (*p1 < *p2) return true; if (*p1++ > *p2++) return false;
-  if (*p1 < *p2) return true; if (*p1++ > *p2++) return false;
-  if (*p1 < *p2) return true; if (*p1++ > *p2++) return false;
-  if (*p1 < *p2) return true; if (*p1++ > *p2++) return false;
-  if (*p1 < *p2) return true; if (*p1++ > *p2++) return false;
-  if (*p1 < *p2) return true; if (*p1++ > *p2++) return false;
-  if (*p1 < *p2) return true;
-  return false;
-  // Supposedly slower
-  //return memcmp (name, other.name, sizeof name) < 0;
+    const char *p1 = name;
+    const char *p2 = other.name;
+    return memcmp (name, other.name, sizeof name) < 0;
 }
 
 
--- a/src/wadnamec.cc	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/wadnamec.cc	Sat Sep 24 14:16:04 2011 +0300
@@ -31,29 +31,27 @@
 #include "wadnamec.h"
 
 
-Wad_name_c::Wad_name_c (const char *string)
+Wad_name_c::Wad_name_c(const char *string)
 {
-  char *p = name;
-  char *pmax = name + 8;
-  while (*string && p < pmax)
-    *p++ = toupper (*string++);
-  *p = '\0';
+    char *p = name;
+    char *pmax = name + 8;
+    while (*string && p < pmax)
+	*p++ = toupper(*string++);
+    *p = '\0';
 }
 
 
-Wad_name_c::Wad_name_c (const char *fmt, ...)
+Wad_name_c::Wad_name_c(const char *fmt, ...)
 {
-  va_list list;
-  va_start (list, fmt);
-  y_vsnprintf (name, sizeof name, fmt, list);
-  va_end (list);
-  y_strupr (name);
+    va_list list;
+    va_start(list, fmt);
+    y_vsnprintf(name, sizeof name, fmt, list);
+    va_end(list);
+    y_strupr(name);
 }
 
 
-int Wad_name_c::cmp (wad_name_t name)
+int Wad_name_c::cmp(wad_name_t name)
 {
-  return y_strnicmp (this->name, name, WAD_NAME);
+    return y_strnicmp(this->name, name, WAD_NAME);
 }
-
-
--- a/src/wadnamec.h	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/wadnamec.h	Sat Sep 24 14:16:04 2011 +0300
@@ -13,10 +13,10 @@
  */
 struct Wad_name_c
 {
-  Wad_name_c (const char *string);
-  Wad_name_c (const char *fmt, ...);
-  int cmp (wad_name_t name);
-  char name[WAD_NAME + 1];
+    Wad_name_c(const char *string);
+      Wad_name_c(const char *fmt, ...);
+    int cmp(wad_name_t name);
+    char name[WAD_NAME + 1];
 };
 
 
--- a/src/wadres.cc	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/wadres.cc	Sat Sep 24 14:16:04 2011 +0300
@@ -32,9 +32,7 @@
 #include "wadres.h"
 
 
-Wad_res::Wad_res (MDirPtr *md) : sprites (md, &master_dir_serial)
+Wad_res::Wad_res(MDirPtr * md):sprites(md, &master_dir_serial)
 {
-  ;
+    ;
 }
-
-
--- a/src/wadres.h	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/wadres.h	Sat Sep 24 14:16:04 2011 +0300
@@ -28,7 +28,7 @@
 */
 
 
-#ifndef YH_WADRES  /* DO NOT INSERT ANYTHING BEFORE THIS LINE */
+#ifndef YH_WADRES		/* DO NOT INSERT ANYTHING BEFORE THIS LINE */
 #define YH_WADRES
 
 
@@ -40,8 +40,7 @@
    lifetime and dependencies. */
 class Wad_res
 {
-  public :
-    Wad_res (MDirPtr *md);
+    public:Wad_res(MDirPtr * md);
     Sprite_dir sprites;
     /* To be added here :
        - Lump_dir patches
@@ -49,11 +48,10 @@
        - Lump_cache textures (TEXTURE[12])
        - Lump_cache pnames   (PNAMES)
        - Lump_cache palette  (PLAYPAL, first 768 bytes) */
-  private :
-};
+  private:};
 
 
 extern Wad_res wad_res;
 
 
-#endif  /* DO NOT ADD ANYTHING AFTER THIS LINE */
+#endif /* DO NOT ADD ANYTHING AFTER THIS LINE */
--- a/src/wads.cc	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/wads.cc	Sat Sep 24 14:16:04 2011 +0300
@@ -33,8 +33,8 @@
 #include "wads.h"
 
 
-MDirPtr MasterDir = NULL;		// The master directory
-Serial_num master_dir_serial;		// The revision# thereof
+MDirPtr MasterDir = NULL;	// The master directory
+Serial_num master_dir_serial;	// The revision# thereof
 
 
 /*
@@ -42,11 +42,11 @@
  *
  *	Return 0 on success, non-zero on failure.
  */
-int file_read_i16 (FILE *fp, i16 *buf, long count)
+int file_read_i16(FILE * fp, i16 * buf, long count)
 {
-  while (count-- > 0)
-    *buf = getc (fp) | (getc (fp) << 8);
-  return feof (fp) || ferror (fp);
+    while (count-- > 0)
+	*buf = getc(fp) | (getc(fp) << 8);
+    return feof(fp) || ferror(fp);
 }
 
 
@@ -55,16 +55,15 @@
  *
  *	Return 0 on success, non-zero on failure.
  */
-int file_read_i32 (FILE *fp, i32 *buf, long count)
+int file_read_i32(FILE * fp, i32 * buf, long count)
 {
-  while (count-- > 0)
-  {
-    *buf++ =    getc (fp)
-      | (      getc (fp) << 8)
-      | ((i32) getc (fp) << 16)
-      | ((i32) getc (fp) << 24);
-  }
-  return feof (fp) || ferror (fp);
+    while (count-- > 0)
+    {
+	*buf++ = getc(fp)
+	    | (getc(fp) << 8)
+	    | ((i32) getc(fp) << 16) | ((i32) getc(fp) << 24);
+    }
+    return feof(fp) || ferror(fp);
 }
 
 
@@ -73,26 +72,26 @@
  *
  *	Return the number of bytes read.
  */
-long file_read_vbytes (FILE *fp, void *buf, long count)
+long file_read_vbytes(FILE * fp, void *buf, long count)
 {
-  long bytes_read_total;
-  size_t bytes_read;
-  size_t bytes_to_read;
+    long bytes_read_total;
+    size_t bytes_read;
+    size_t bytes_to_read;
 
-  bytes_read_total = 0;
-  bytes_to_read    = 0x8000;
-  while (count > 0)
-  {
-    if (count <= 0x8000)
-      bytes_to_read = (size_t) count;
-    bytes_read = fread (buf, 1, bytes_to_read, fp);
-    bytes_read_total += bytes_read;
-    if (bytes_read != bytes_to_read)
-      break;
-    buf = (char *) buf + bytes_read;
-    count -= bytes_read;
-  }
-  return bytes_read_total;
+    bytes_read_total = 0;
+    bytes_to_read = 0x8000;
+    while (count > 0)
+    {
+	if (count <= 0x8000)
+	    bytes_to_read = (size_t) count;
+	bytes_read = fread(buf, 1, bytes_to_read, fp);
+	bytes_read_total += bytes_read;
+	if (bytes_read != bytes_to_read)
+	    break;
+	buf = (char *) buf + bytes_read;
+	count -= bytes_read;
+    }
+    return bytes_read_total;
 }
 
 
@@ -101,9 +100,9 @@
  *
  *	Return 0 on success, non-zero on failure.
  */
-int file_read_bytes (FILE *fp, void *buf, long count)
+int file_read_bytes(FILE * fp, void *buf, long count)
 {
-  return file_read_vbytes (fp, buf, count) != count;
+    return file_read_vbytes(fp, buf, count) != count;
 }
 
 
@@ -112,10 +111,10 @@
  *
  *	Does no error checking.
  */
-void file_write_i16 (FILE *fd, i16 buf)
+void file_write_i16(FILE * fd, i16 buf)
 {
-  putc (       buf & 0xff, fd);
-  putc ((buf >> 8) & 0xff, fd);
+    putc(buf & 0xff, fd);
+    putc((buf >> 8) & 0xff, fd);
 }
 
 
@@ -124,17 +123,17 @@
  *
  *	Does no error checking.
  */
-void file_write_i32 (FILE *fd, i32 buf, long count)
+void file_write_i32(FILE * fd, i32 buf, long count)
 {
-  /* It would probably be more efficient to swap bytes in-core
-     and write the whole i32 at once. */
-  while (count-- > 0)
-  {
-    putc (        buf & 0xff, fd);
-    putc ((buf >>  8) & 0xff, fd);
-    putc ((buf >> 16) & 0xff, fd);
-    putc ((buf >> 24) & 0xff, fd);
-  }
+    /* It would probably be more efficient to swap bytes in-core
+       and write the whole i32 at once. */
+    while (count-- > 0)
+    {
+	putc(buf & 0xff, fd);
+	putc((buf >> 8) & 0xff, fd);
+	putc((buf >> 16) & 0xff, fd);
+	putc((buf >> 24) & 0xff, fd);
+    }
 }
 
 
@@ -155,15 +154,15 @@
  *
  *	Does no error checking.
  */
-void file_write_name (FILE *fd, const char *name)
+void file_write_name(FILE * fd, const char *name)
 {
-  const unsigned char *const p0 = (const unsigned char *) name;
-  const unsigned char *p = p0;  // "unsigned" for toupper()'s sake
+    const unsigned char *const p0 = (const unsigned char *) name;
+    const unsigned char *p = p0;	// "unsigned" for toupper()'s sake
 
-  for (; p - p0 < (ptrdiff_t) WAD_NAME && *p; p++)
-    putc (toupper (*p), fd);
-  for (; p - p0 < (ptrdiff_t) WAD_NAME; p++)
-    putc ('\0', fd);
+    for (; p - p0 < (ptrdiff_t) WAD_NAME && *p; p++)
+	putc(toupper(*p), fd);
+    for (; p - p0 < (ptrdiff_t) WAD_NAME; p++)
+	putc('\0', fd);
 }
 
 
@@ -171,31 +170,31 @@
    find an entry in the master directory
 */
 
-MDirPtr FindMasterDir (MDirPtr from, const char *name)
+MDirPtr FindMasterDir(MDirPtr from, const char *name)
 {
-  while (from)
-  {
-    if (! y_strnicmp (from->dir.name, name, WAD_NAME))
-      break;
-    from = from->next;
-  }
-  return from;
+    while (from)
+    {
+	if (!y_strnicmp(from->dir.name, name, WAD_NAME))
+	    break;
+	from = from->next;
+    }
+    return from;
 }
 
 
 /*
  *	Find an entry in the master directory
  */
-MDirPtr FindMasterDir (MDirPtr from, const char *name1, const char *name2)
+MDirPtr FindMasterDir(MDirPtr from, const char *name1, const char *name2)
 {
-  while (from)
+    while (from)
     {
-    if (! y_strnicmp (from->dir.name, name1, WAD_NAME)
-     || ! y_strnicmp (from->dir.name, name2, WAD_NAME))
-      break;
-    from = from->next;
+	if (!y_strnicmp(from->dir.name, name1, WAD_NAME)
+	    || !y_strnicmp(from->dir.name, name2, WAD_NAME))
+	    break;
+	from = from->next;
     }
-  return from;
+    return from;
 }
 
 
@@ -203,19 +202,19 @@
    output bytes to a binary file with error checking
 */
 
-void WriteBytes (FILE *file, const void *buf, long size)
+void WriteBytes(FILE * file, const void *buf, long size)
 {
-  if (! Registered)
-    return;
-  while (size > 0x8000)
-  {
-    if (fwrite (buf, 1, 0x8000, file) != 0x8000)
-      fatal_error ("error writing to file");
-    buf = (const char *) buf + 0x8000;
-    size -= 0x8000;
-  }
-  if (fwrite (buf, 1, size, file) != (size_t) size)
-    fatal_error ("error writing to file");
+    if (!Registered)
+	return;
+    while (size > 0x8000)
+    {
+	if (fwrite(buf, 1, 0x8000, file) != 0x8000)
+	    fatal_error("error writing to file");
+	buf = (const char *) buf + 0x8000;
+	size -= 0x8000;
+    }
+    if (fwrite(buf, 1, size, file) != (size_t) size)
+	fatal_error("error writing to file");
 }
 
 
@@ -230,41 +229,40 @@
  *	source file, 2 if there was a write error on destination
  *	file.
  */
-int copy_bytes (FILE *dest, FILE *source, long size)
+int copy_bytes(FILE * dest, FILE * source, long size)
 {
-  int          rc      = 0;
-  void        *data    = 0;
-  const size_t chunksz = 0x4000;
+    int rc = 0;
+    void *data = 0;
+    const size_t chunksz = 0x4000;
 
-  data = GetMemory (chunksz + 2);
-  while (size > chunksz)
-  {
-    if (fread (data, 1, chunksz, source) != chunksz)
+    data = GetMemory(chunksz + 2);
+    while (size > chunksz)
     {
-      rc = 1;
-      goto byebye;
-    }
-    if (fwrite (data, 1, chunksz, dest) != chunksz)
-    {
-      rc = 2;
-      goto byebye;
+	if (fread(data, 1, chunksz, source) != chunksz)
+	{
+	    rc = 1;
+	    goto byebye;
+	}
+	if (fwrite(data, 1, chunksz, dest) != chunksz)
+	{
+	    rc = 2;
+	    goto byebye;
+	}
+	size -= chunksz;
     }
-    size -= chunksz;
-  }
-  if (fread (data, 1, size, source) != (size_t) size)
-  {
-    rc = 1;
-    goto byebye;
-  }
-  if (fwrite (data, 1, size, dest) != (size_t) size)
-  {
-    rc = 2;
-    goto byebye;
-  }
+    if (fread(data, 1, size, source) != (size_t) size)
+    {
+	rc = 1;
+	goto byebye;
+    }
+    if (fwrite(data, 1, size, dest) != (size_t) size)
+    {
+	rc = 2;
+	goto byebye;
+    }
 
-byebye:
-  if (data != 0)
-    FreeMemory (data);
-  return rc;
+  byebye:
+    if (data != 0)
+	FreeMemory(data);
+    return rc;
 }
-
--- a/src/wads.h	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/wads.h	Sat Sep 24 14:16:04 2011 +0300
@@ -4,27 +4,27 @@
  */
 
 
-#ifndef YH_WADS  /* DO NOT INSERT ANYTHING BEFORE THIS LINE */
+#ifndef YH_WADS			/* DO NOT INSERT ANYTHING BEFORE THIS LINE */
 #define YH_WADS
 
 
-int  file_read_i16    (FILE *,  i16 *buf, long count = 1);
-int  file_read_i32    (FILE *,  i32 *buf, long count = 1);
-long file_read_vbytes (FILE *, void *buf, long count);
-int  file_read_bytes  (FILE *, void *buf, long count);
-void file_write_i16   (FILE *,  i16 buf);
-void file_write_i32   (FILE *,  i32 buf, long count = 1);
-void file_write_name  (FILE *, const char *name);
-void WriteBytes       (FILE *, const void *, long);
-int  copy_bytes       (FILE *dest, FILE *source, long size);
+int file_read_i16(FILE *, i16 * buf, long count = 1);
+int file_read_i32(FILE *, i32 * buf, long count = 1);
+long file_read_vbytes(FILE *, void *buf, long count);
+int file_read_bytes(FILE *, void *buf, long count);
+void file_write_i16(FILE *, i16 buf);
+void file_write_i32(FILE *, i32 buf, long count = 1);
+void file_write_name(FILE *, const char *name);
+void WriteBytes(FILE *, const void *, long);
+int copy_bytes(FILE * dest, FILE * source, long size);
 
 #if 0
-void wad_seek        (WadPtr, long offset);
-void wad_read_bytes  (WadPtr, void *buf, long count);
-long wad_read_vbytes (WadPtr, void *buf, long count);
- i16 wad_read_i16    (WadPtr);
-void wad_read_i16    (WadPtr,  i16 *buf);
-void wad_read_i32    (WadPtr,  i32 *buf, long count = 1);
+void wad_seek(WadPtr, long offset);
+void wad_read_bytes(WadPtr, void *buf, long count);
+long wad_read_vbytes(WadPtr, void *buf, long count);
+i16 wad_read_i16(WadPtr);
+void wad_read_i16(WadPtr, i16 * buf);
+void wad_read_i32(WadPtr, i32 * buf, long count = 1);
 #endif
 
 
@@ -33,7 +33,7 @@
  *	flat_name_cmp
  *	Compare two flat names like strcmp() compares two strings.
  */
-inline int flat_name_cmp (const char *name1, const char *name2)
+inline int flat_name_cmp(const char *name1, const char *name2)
 {
 }
 
@@ -43,7 +43,7 @@
  *	Compare two texture names like strcmp() compares two strings.
  *	T
  */
-inline int tex_name_cmp (const char *name1, const char *name2)
+inline int tex_name_cmp(const char *name1, const char *name2)
 {
 }
 
@@ -52,10 +52,10 @@
  *	sprite_name_cmp
  *	Compare two sprite names like strcmp() compares two strings.
  */
-inline int sprite_name_cmp (const char *name1, const char *name2)
+inline int sprite_name_cmp(const char *name1, const char *name2)
 {
 }
 #endif
 
 
-#endif  /* DO NOT ADD ANYTHING AFTER THIS LINE */
+#endif /* DO NOT ADD ANYTHING AFTER THIS LINE */
--- a/src/wads2.cc	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/wads2.cc	Sat Sep 24 14:16:04 2011 +0300
@@ -29,7 +29,7 @@
 
 
 #include "yadex.h"
-#include "game.h"	/* yg_picture_format */
+#include "game.h"		/* yg_picture_format */
 #include "serialnum.h"
 #include "wadfile.h"
 #include "wadlist.h"
@@ -37,8 +37,8 @@
 #include "wads2.h"
 
 
-static char *locate_pwad (const char *filename);
-static int level_name_order (const void *p1, const void *p2);
+static char *locate_pwad(const char *filename);
+static int level_name_order(const void *p1, const void *p2);
 
 
 /*
@@ -49,55 +49,60 @@
  *
  *	Return 0 on success, non-zero on failure.
  */
-int OpenMainWad (const char *filename)
+int OpenMainWad(const char *filename)
 {
-MDirPtr lastp, newp;
-long n;
-Wad_file *wf;
+    MDirPtr lastp, newp;
+    long n;
+    Wad_file *wf;
 
 /* open the wad file */
-printf ("Loading iwad: %s...\n", filename);
-wf = BasicWadOpen (filename, yg_picture_format);
-if (wf == 0)
-   return 1;
-if (strncmp (wf->type, "IWAD", 4))
-   warn ("%.128s: is a pwad, not an iwad. Will use it anyway.\n", filename);
+    printf("Loading iwad: %s...\n", filename);
+    wf = BasicWadOpen(filename, yg_picture_format);
+    if (wf == 0)
+	return 1;
+    if (strncmp(wf->type, "IWAD", 4))
+	warn("%.128s: is a pwad, not an iwad. Will use it anyway.\n",
+	     filename);
 
 /* create the master directory */
-lastp = NULL;
-for (n = 0; n < wf->dirsize; n++)
-   {
-   newp = (MDirPtr) GetMemory (sizeof (struct MasterDirectory));
-   newp->next = NULL;
-   newp->wadfile = wf;
-   memcpy (&(newp->dir), &(wf->directory[n]), sizeof (struct Directory));
-   if (MasterDir)
-      lastp->next = newp;
-   else
-      MasterDir = newp;
-   lastp = newp;
-   }
-master_dir_serial.bump ();
+    lastp = NULL;
+    for (n = 0; n < wf->dirsize; n++)
+    {
+	newp = (MDirPtr) GetMemory(sizeof(struct MasterDirectory));
+	newp->next = NULL;
+	newp->wadfile = wf;
+	memcpy(&(newp->dir), &(wf->directory[n]), sizeof(struct Directory));
+	if (MasterDir)
+	    lastp->next = newp;
+	else
+	    MasterDir = newp;
+	lastp = newp;
+    }
+    master_dir_serial.bump();
 
 /* check if registered version */
-if (FindMasterDir (MasterDir, "E2M1") == NULL
- && FindMasterDir (MasterDir, "MAP01") == NULL
- && FindMasterDir (MasterDir, "MAP33") == NULL
- && strcmp (Game, "doom02")
- && strcmp (Game, "doom04")
- && strcmp (Game, "doom05")
- && strcmp (Game, "doompr"))
-   {
-   printf ("   *-----------------------------------------------------*\n");
-   printf ("   | Warning: this is the shareware version of the game. |\n");
-   printf ("   |     You won't be allowed to save your changes.      |\n");
-   printf ("   |       PLEASE REGISTER YOUR COPY OF THE GAME.        |\n");
-   printf ("   *-----------------------------------------------------*\n");
-   Registered = false; // If you remove this, bad things will happen to you...
-   }
-else
-   Registered = true;
-return 0;
+    if (FindMasterDir(MasterDir, "E2M1") == NULL
+	&& FindMasterDir(MasterDir, "MAP01") == NULL
+	&& FindMasterDir(MasterDir, "MAP33") == NULL
+	&& strcmp(Game, "doom02")
+	&& strcmp(Game, "doom04")
+	&& strcmp(Game, "doom05") && strcmp(Game, "doompr"))
+    {
+	printf
+	    ("   *-----------------------------------------------------*\n");
+	printf
+	    ("   | Warning: this is the shareware version of the game. |\n");
+	printf
+	    ("   |     You won't be allowed to save your changes.      |\n");
+	printf
+	    ("   |       PLEASE REGISTER YOUR COPY OF THE GAME.        |\n");
+	printf
+	    ("   *-----------------------------------------------------*\n");
+	Registered = false;	// If you remove this, bad things will happen to you...
+    }
+    else
+	Registered = true;
+    return 0;
 }
 
 
@@ -109,33 +114,34 @@
  *
  *	Return 0 on success, non-zero on failure.
  */
-int OpenPatchWad (const char *filename)
+int OpenPatchWad(const char *filename)
 {
-Wad_file * wad;
-MDirPtr mdir = 0;
-long n;
-char entryname[WAD_NAME + 1];
-const char *entry_type = 0;
-char *real_name;
-int nitems = 0;		// Number of items in group of flats/patches/sprites
+    Wad_file *wad;
+    MDirPtr mdir = 0;
+    long n;
+    char entryname[WAD_NAME + 1];
+    const char *entry_type = 0;
+    char *real_name;
+    int nitems = 0;		// Number of items in group of flats/patches/sprites
 
 // Look for the file and ignore it if it doesn't exist
-real_name = locate_pwad (filename);
-if (real_name == NULL)
-   {
-   warn ("%.128s: not found.\n", filename);
-   return 1;
-   }
+    real_name = locate_pwad(filename);
+    if (real_name == NULL)
+    {
+	warn("%.128s: not found.\n", filename);
+	return 1;
+    }
 
 /* open the wad file */
-printf ("Loading pwad: %s...\n", real_name);
+    printf("Loading pwad: %s...\n", real_name);
 // By default, assume pwads use the normal picture format.
-wad = BasicWadOpen (real_name, YGPF_NORMAL);
-FreeMemory (real_name);
-if (! wad)
-   return 1;
-if (strncmp (wad->type, "PWAD", 4))
-   warn ("%.128s: is an iwad, not a pwad. Will use it anyway.\n", filename);
+    wad = BasicWadOpen(real_name, YGPF_NORMAL);
+    FreeMemory(real_name);
+    if (!wad)
+	return 1;
+    if (strncmp(wad->type, "PWAD", 4))
+	warn("%.128s: is an iwad, not a pwad. Will use it anyway.\n",
+	     filename);
 
 /* alter the master directory */
 
@@ -147,212 +153,217 @@
    FF_END to end a group of flats if the following entry is neither
    F_END nor F?_START. */
 
-int state = 0;
-int replaces = 0;
-int state_prev;
-int replaces_prev;
-int names = 0;		// Number of names already printed on current line
-const char *entry_type_prev;
-typedef char level_list_item_t[WAD_NAME];
-level_list_item_t *level_list = 0;
-size_t nlevels = 0;
-for (n = 0; n < wad->dirsize; n++)
-   {
-   strncpy (entryname, wad->directory[n].name, WAD_NAME);
-   entryname[WAD_NAME] = '\0';
-   state_prev = state;
-   replaces_prev = replaces;
-   entry_type_prev = entry_type;
-   if (state == 0)
-      {
-      if (! strcmp (entryname, "F_START")
-       || ! strcmp (entryname, "P_START")
-       || ! strcmp (entryname, "S_START"))
-	 {
-	 entry_type = "label";
-	 replaces   = 0;
-	 }
-      // DeuTex puts flats between FF_START and FF_END/F_END.
-      // All lumps between those markers are assumed
-      // to be flats.
-      else if (! strncmp (entryname, "FF_START", WAD_NAME))
-	 {
-	 state      = 'f';
-	 entry_type = "group of flats";
-	 replaces   = 0;
-         nitems     = 0;
-	 }
-      // DeuTex puts patches between PP_START and PP_END.
-      // All lumps between those markers are assumed
-      // to be patches.
-      else if (! strncmp (entryname, "PP_START", WAD_NAME))
-	 {
-	 state      = 'p';
-	 entry_type = "group of patches";
-	 replaces   = 0;
-         nitems     = 0;
-	 }
-      // DeuTex puts patches between SS_START and SS_END/S_END.
-      // All lumps between those markers are assumed
-      // to be sprites.
-      else if (! strncmp (entryname, "SS_START", WAD_NAME))
-	 {
-	 state      = 's';
-	 entry_type = "group of sprites";
-	 replaces   = 0;
-         nitems     = 0;
-	 }
-      else
-	 {
-	 mdir = FindMasterDir (MasterDir, entryname);
-	 replaces = mdir != NULL;
-	 /* if it is a level, do the same thing for the next 10 entries too */
-	 if (levelname2levelno (entryname))
+    int state = 0;
+    int replaces = 0;
+    int state_prev;
+    int replaces_prev;
+    int names = 0;		// Number of names already printed on current line
+    const char *entry_type_prev;
+    typedef char level_list_item_t[WAD_NAME];
+    level_list_item_t *level_list = 0;
+    size_t nlevels = 0;
+    for (n = 0; n < wad->dirsize; n++)
+    {
+	strncpy(entryname, wad->directory[n].name, WAD_NAME);
+	entryname[WAD_NAME] = '\0';
+	state_prev = state;
+	replaces_prev = replaces;
+	entry_type_prev = entry_type;
+	if (state == 0)
+	{
+	    if (!strcmp(entryname, "F_START")
+		|| !strcmp(entryname, "P_START")
+		|| !strcmp(entryname, "S_START"))
+	    {
+		entry_type = "label";
+		replaces = 0;
+	    }
+	    // DeuTex puts flats between FF_START and FF_END/F_END.
+	    // All lumps between those markers are assumed
+	    // to be flats.
+	    else if (!strncmp(entryname, "FF_START", WAD_NAME))
+	    {
+		state = 'f';
+		entry_type = "group of flats";
+		replaces = 0;
+		nitems = 0;
+	    }
+	    // DeuTex puts patches between PP_START and PP_END.
+	    // All lumps between those markers are assumed
+	    // to be patches.
+	    else if (!strncmp(entryname, "PP_START", WAD_NAME))
 	    {
-	    state = 11;
-	    entry_type = "level";
-	    // Add to list of level names
+		state = 'p';
+		entry_type = "group of patches";
+		replaces = 0;
+		nitems = 0;
+	    }
+	    // DeuTex puts patches between SS_START and SS_END/S_END.
+	    // All lumps between those markers are assumed
+	    // to be sprites.
+	    else if (!strncmp(entryname, "SS_START", WAD_NAME))
+	    {
+		state = 's';
+		entry_type = "group of sprites";
+		replaces = 0;
+		nitems = 0;
+	    }
+	    else
 	    {
-	    level_list_item_t *new_list;
-	    new_list = (level_list_item_t *)
-	       realloc (level_list, (nlevels + 1) * sizeof *level_list);
-	    if (new_list != 0)
-	       {
-	       level_list = new_list;
-	       strncpy (level_list[nlevels], entryname, sizeof *level_list);
-	       nlevels++;
-	       }
-	    }
+		mdir = FindMasterDir(MasterDir, entryname);
+		replaces = mdir != NULL;
+		/* if it is a level, do the same thing for the next 10 entries too */
+		if (levelname2levelno(entryname))
+		{
+		    state = 11;
+		    entry_type = "level";
+		    // Add to list of level names
+		    {
+			level_list_item_t *new_list;
+			new_list = (level_list_item_t *)
+			    realloc(level_list,
+				    (nlevels + 1) * sizeof *level_list);
+			if (new_list != 0)
+			{
+			    level_list = new_list;
+			    strncpy(level_list[nlevels], entryname,
+				    sizeof *level_list);
+			    nlevels++;
+			}
+		    }
+		}
+		else
+		    entry_type = "entry";
 	    }
-	 else
-	    entry_type = "entry";
-	 }
-      if (n == 0
-	  || state_prev      != state
-	  || replaces_prev   != replaces
-	  || entry_type_prev != entry_type)
-         {
-	 if (n > 0)
-	    verbmsg ("\n");
-	 names = 0;
-	 verbmsg ("  %s %s", replaces ? "Updating" : "Adding new", entry_type);
-         }
-      if (names >= 6)
-         {
-	 verbmsg ("\n  %-*s %-*s",
-	     strlen (replaces ? "Updating" : "Adding new"), "",
-	     strlen (entry_type), "");
-	 names = 0;
-         }
-      verbmsg  (" %-*s", WAD_NAME, entryname);
-      names++;
-      if ((*entry_type == 'm' || *entry_type == 'l') && wad->directory[n].size)
-	 verbmsg (" warning: non-zero length (%ld)", wad->directory[n].size);
-      }
-   // Either F_END or FF_END mark the end of a
-   // DeuTex-generated group of flats.
-   else if (state == 'f')
-      {
-      if (! strncmp (entryname, "F_END", WAD_NAME)
-	  || ! strncmp (entryname, "FF_END", WAD_NAME))
-         {
-	 state = 0;
-         verbmsg ("/%.*s (%d flats)", WAD_NAME, entryname, nitems);
-         }
-      // Of course, F?_START and F?_END don't count
-      // toward the number of flats in the group.
-      else if (! (*entryname == 'F'
-                  && (! strncmp (entryname + 2, "_START", 6)
-                      || ! strcmp (entryname + 2, "_END"))))
-         nitems++;
-      }
-   // PP_END marks the end of a DeuTex-generated group of patches.
-   else if (state == 'p')
-      {
-      if (! strncmp (entryname, "PP_END", WAD_NAME))
-         {
-         state = 0;
-         verbmsg ("/PP_END (%d patches)", nitems);
-         }
-      // Of course, P?_START and P?_END don't count
-      // toward the number of flats in the group.
-      else if (! (*entryname == 'P'
-                  && (! strncmp (entryname + 2, "_START", 6)
-                      || ! strcmp (entryname + 2, "_END"))))
-         nitems++;
-      }
-   // Either S_END or SS_END mark the end of a
-   // DeuTex-generated group of sprites.
-   else if (state == 's')
-      {
-      if (! strncmp (entryname, "S_END", WAD_NAME)
-	  || ! strncmp (entryname, "SS_END", WAD_NAME))
-         {
-	 state = 0;
-         verbmsg ("/%.*s (%d sprites)", WAD_NAME, entryname, nitems);
-         }
-      // Of course, S?_START and S?_END don't count
-      // toward the number of sprites in the group.
-      else if (! (*entryname == 'S'
-                  && (! strncmp (entryname + 2, "_START", 6)
-                      || ! strcmp (entryname + 2, "_END"))))
-         nitems++;
-      }
-     
-   /* if this entry is not in the master directory, then add it */
-   if (!replaces)
-      {
-      mdir = MasterDir;
-      while (mdir->next)
-	 mdir = mdir->next;
-      mdir->next = (MDirPtr) GetMemory (sizeof (struct MasterDirectory));
-      mdir = mdir->next;
-      mdir->next = NULL;
-      }
-   /* else, simply replace it */
-   mdir->wadfile = wad;
-   memcpy (&(mdir->dir), &(wad->directory[n]), sizeof (struct Directory));
-   mdir = mdir->next;
+	    if (n == 0
+		|| state_prev != state
+		|| replaces_prev != replaces || entry_type_prev != entry_type)
+	    {
+		if (n > 0)
+		    verbmsg("\n");
+		names = 0;
+		verbmsg("  %s %s", replaces ? "Updating" : "Adding new",
+			entry_type);
+	    }
+	    if (names >= 6)
+	    {
+		verbmsg("\n  %-*s %-*s",
+			strlen(replaces ? "Updating" : "Adding new"), "",
+			strlen(entry_type), "");
+		names = 0;
+	    }
+	    verbmsg(" %-*s", WAD_NAME, entryname);
+	    names++;
+	    if ((*entry_type == 'm' || *entry_type == 'l')
+		&& wad->directory[n].size)
+		verbmsg(" warning: non-zero length (%ld)",
+			wad->directory[n].size);
+	}
+	// Either F_END or FF_END mark the end of a
+	// DeuTex-generated group of flats.
+	else if (state == 'f')
+	{
+	    if (!strncmp(entryname, "F_END", WAD_NAME)
+		|| !strncmp(entryname, "FF_END", WAD_NAME))
+	    {
+		state = 0;
+		verbmsg("/%.*s (%d flats)", WAD_NAME, entryname, nitems);
+	    }
+	    // Of course, F?_START and F?_END don't count
+	    // toward the number of flats in the group.
+	    else if (!(*entryname == 'F'
+		       && (!strncmp(entryname + 2, "_START", 6)
+			   || !strcmp(entryname + 2, "_END"))))
+		nitems++;
+	}
+	// PP_END marks the end of a DeuTex-generated group of patches.
+	else if (state == 'p')
+	{
+	    if (!strncmp(entryname, "PP_END", WAD_NAME))
+	    {
+		state = 0;
+		verbmsg("/PP_END (%d patches)", nitems);
+	    }
+	    // Of course, P?_START and P?_END don't count
+	    // toward the number of flats in the group.
+	    else if (!(*entryname == 'P'
+		       && (!strncmp(entryname + 2, "_START", 6)
+			   || !strcmp(entryname + 2, "_END"))))
+		nitems++;
+	}
+	// Either S_END or SS_END mark the end of a
+	// DeuTex-generated group of sprites.
+	else if (state == 's')
+	{
+	    if (!strncmp(entryname, "S_END", WAD_NAME)
+		|| !strncmp(entryname, "SS_END", WAD_NAME))
+	    {
+		state = 0;
+		verbmsg("/%.*s (%d sprites)", WAD_NAME, entryname, nitems);
+	    }
+	    // Of course, S?_START and S?_END don't count
+	    // toward the number of sprites in the group.
+	    else if (!(*entryname == 'S'
+		       && (!strncmp(entryname + 2, "_START", 6)
+			   || !strcmp(entryname + 2, "_END"))))
+		nitems++;
+	}
 
-   if (state > 0 && state <= 11)
-      state--;
-   }
-verbmsg ("\n");
-master_dir_serial.bump ();
+	/* if this entry is not in the master directory, then add it */
+	if (!replaces)
+	{
+	    mdir = MasterDir;
+	    while (mdir->next)
+		mdir = mdir->next;
+	    mdir->next = (MDirPtr) GetMemory(sizeof(struct MasterDirectory));
+	    mdir = mdir->next;
+	    mdir->next = NULL;
+	}
+	/* else, simply replace it */
+	mdir->wadfile = wad;
+	memcpy(&(mdir->dir), &(wad->directory[n]), sizeof(struct Directory));
+	mdir = mdir->next;
+
+	if (state > 0 && state <= 11)
+	    state--;
+    }
+    verbmsg("\n");
+    master_dir_serial.bump();
 
 // Print list of levels found in this pwad
-if (level_list != 0)
-   {
-   printf ("  Levels: ");
-   qsort (level_list, nlevels, sizeof *level_list, level_name_order);
-   for (size_t n = 0; n < nlevels; n++)
-      {
-      int prev = n > 0           ? levelname2rank (level_list[n - 1]) : INT_MIN;
-      int cur  =                   levelname2rank (level_list[n    ]);
-      int next = n + 1 < nlevels ? levelname2rank (level_list[n + 1]) : INT_MAX;
-      if (cur != prev + 1 || cur != next - 1)
-         {
-         if (cur == prev + 1)
-	    putchar ('-');
-	 else if (n > 0)
-	    putchar (' ');
-         printf ("%.*s", (int) sizeof *level_list, level_list[n]);
-         }
-      }
-   putchar ('\n');
-   free (level_list);
-   }
-return 0;
+    if (level_list != 0)
+    {
+	printf("  Levels: ");
+	qsort(level_list, nlevels, sizeof *level_list, level_name_order);
+	for (size_t n = 0; n < nlevels; n++)
+	{
+	    int prev = n > 0 ? levelname2rank(level_list[n - 1]) : INT_MIN;
+	    int cur = levelname2rank(level_list[n]);
+	    int next =
+		n + 1 < nlevels ? levelname2rank(level_list[n + 1]) : INT_MAX;
+	    if (cur != prev + 1 || cur != next - 1)
+	    {
+		if (cur == prev + 1)
+		    putchar('-');
+		else if (n > 0)
+		    putchar(' ');
+		printf("%.*s", (int) sizeof *level_list, level_list[n]);
+	    }
+	}
+	putchar('\n');
+	free(level_list);
+    }
+    return 0;
 }
 
 
 /*
  *	level_name_order - -cmp-style comparison of two level names
  */
-static int level_name_order (const void *p1, const void *p2)
+static int level_name_order(const void *p1, const void *p2)
 {
-return levelname2rank ((const char *) p1)
-     - levelname2rank ((const char *) p2);
+    return levelname2rank((const char *) p1)
+	- levelname2rank((const char *) p2);
 }
 
 
@@ -361,45 +372,45 @@
  *
  *	Close all the wad, deallocating the wad file structures.
  */
-void CloseWadFiles ()
+void CloseWadFiles()
 {
-MDirPtr curd, nextd;
+    MDirPtr curd, nextd;
 
 // Close the wad files
-Wad_file *wf;
-wad_list.rewind ();
-while (wad_list.get (wf))
-   wad_list.del ();
+    Wad_file *wf;
+    wad_list.rewind();
+    while (wad_list.get(wf))
+	wad_list.del();
 
 // Delete the master directory
-curd = MasterDir;
-MasterDir = NULL;
-while (curd)
-   {
-   nextd = curd->next;
-   FreeMemory (curd);
-   curd = nextd;
-   }
-master_dir_serial.bump ();
+    curd = MasterDir;
+    MasterDir = NULL;
+    while (curd)
+    {
+	nextd = curd->next;
+	FreeMemory(curd);
+	curd = nextd;
+    }
+    master_dir_serial.bump();
 }
 
 
 /*
  *	CloseUnusedWadFiles - forget unused patch wad files
  */
-void CloseUnusedWadFiles ()
+void CloseUnusedWadFiles()
 {
-Wad_file *wf;
-wad_list.rewind ();
-while (wad_list.get (wf))
-   {
-   // Check if the wad file is used by a directory entry
-   MDirPtr mdir = MasterDir;
-   while (mdir && mdir->wadfile != wf)
-      mdir = mdir->next;
-   if (mdir == 0)
-      wad_list.del ();
-   }
+    Wad_file *wf;
+    wad_list.rewind();
+    while (wad_list.get(wf))
+    {
+	// Check if the wad file is used by a directory entry
+	MDirPtr mdir = MasterDir;
+	while (mdir && mdir->wadfile != wf)
+	    mdir = mdir->next;
+	if (mdir == 0)
+	    wad_list.del();
+    }
 }
 
 
@@ -411,9 +422,9 @@
  *
  *	Return a null pointer on error.
  */
-Wad_file *BasicWadOpen (const char *filename, ygpf_t pic_format)
+Wad_file *BasicWadOpen(const char *filename, ygpf_t pic_format)
 {
-bool fail = false;
+    bool fail = false;
 
 /* If this wad is already open, close it first (it's not always
    possible to open the same file twice). Also position the
@@ -423,155 +434,160 @@
    
    FIXME if reopening fails, we're left in the cold. I'm not
    sure how to avoid that, though. */
-{
-   Wad_file *dummy;
-   wad_list.rewind ();
-   while (wad_list.get (dummy))
-      if (fncmp (filename, dummy->filename) == 0)
-	 {
-	 wad_list.del ();
-	 break;
-	 }
-}
+    {
+	Wad_file *dummy;
+	wad_list.rewind();
+	while (wad_list.get(dummy))
+	    if (fncmp(filename, dummy->filename) == 0)
+	    {
+		wad_list.del();
+		break;
+	    }
+    }
 
 // Create a new Wad_file
-Wad_file *wf = new Wad_file;
-wf->pic_format_ = pic_format;
-wf->directory   = 0;
-wf->filename    = (char *) GetMemory (strlen (filename) + 1);
-strcpy (wf->filename, filename);
+    Wad_file *wf = new Wad_file;
+    wf->pic_format_ = pic_format;
+    wf->directory = 0;
+    wf->filename = (char *) GetMemory(strlen(filename) + 1);
+    strcpy(wf->filename, filename);
 
 // Open the wad and read its header.
-wf->fp = fopen (filename, "rb");
-if (wf->fp == 0)
-   {
-   printf ("%.128s: %s\n", filename, strerror (errno));
-   fail = true;
-   goto byebye;
-   }
-{
-bool e = file_read_bytes (wf->fp, wf->type, 4);
-e     |= file_read_i32   (wf->fp, &wf->dirsize);
-e     |= file_read_i32   (wf->fp, &wf->dirstart);
-if (e || memcmp (wf->type, "IWAD", 4) != 0 && memcmp (wf->type, "PWAD", 4) != 0)
-   {
-   printf ("%.128s: not a wad (bad header)\n", filename);
-   fail = true;
-   goto byebye;
-   }
-}
-verbmsg ("  Type %.4s, directory has %ld entries at offset %08lXh\n",
-   wf->type, (long) wf->dirsize, (long) wf->dirstart);
+    wf->fp = fopen(filename, "rb");
+    if (wf->fp == 0)
+    {
+	printf("%.128s: %s\n", filename, strerror(errno));
+	fail = true;
+	goto byebye;
+    }
+    {
+	bool e = file_read_bytes(wf->fp, wf->type, 4);
+	e |= file_read_i32(wf->fp, &wf->dirsize);
+	e |= file_read_i32(wf->fp, &wf->dirstart);
+	if (e || memcmp(wf->type, "IWAD", 4) != 0
+	    && memcmp(wf->type, "PWAD", 4) != 0)
+	{
+	    printf("%.128s: not a wad (bad header)\n", filename);
+	    fail = true;
+	    goto byebye;
+	}
+    }
+    verbmsg("  Type %.4s, directory has %ld entries at offset %08lXh\n",
+	    wf->type, (long) wf->dirsize, (long) wf->dirstart);
 
 // Load the directory of the wad
-wf->directory = (DirPtr) GetMemory ((long) sizeof (struct Directory)
-   * wf->dirsize);
-if (fseek (wf->fp, wf->dirstart, SEEK_SET) != 0)
-   {
-   printf ("%.128s: can't seek to directory at %08lXh\n",
-      filename, wf->dirstart);
-   fail = true;
-   goto byebye;
-   }
-for (i32 n = 0; n < wf->dirsize; n++)
-   {
-   bool e  = file_read_i32   (wf->fp, &wf->directory[n].start);
-   e      |= file_read_i32   (wf->fp, &wf->directory[n].size);
-   e      |= file_read_bytes (wf->fp, wf->directory[n].name, WAD_NAME);
-   if (e)
-      {
-      printf ("%.128s: read error on directory entry %ld\n", filename, (long)n);
-      fail = true;
-      goto byebye;
-      }
-   }
+    wf->directory = (DirPtr) GetMemory((long) sizeof(struct Directory)
+				       * wf->dirsize);
+    if (fseek(wf->fp, wf->dirstart, SEEK_SET) != 0)
+    {
+	printf("%.128s: can't seek to directory at %08lXh\n",
+	       filename, wf->dirstart);
+	fail = true;
+	goto byebye;
+    }
+    for (i32 n = 0; n < wf->dirsize; n++)
+    {
+	bool e = file_read_i32(wf->fp, &wf->directory[n].start);
+	e |= file_read_i32(wf->fp, &wf->directory[n].size);
+	e |= file_read_bytes(wf->fp, wf->directory[n].name, WAD_NAME);
+	if (e)
+	{
+	    printf("%.128s: read error on directory entry %ld\n", filename,
+		   (long) n);
+	    fail = true;
+	    goto byebye;
+	}
+    }
 
 // Insert the new wad in the list
-wad_list.insert (wf);
+    wad_list.insert(wf);
 
-byebye:
-if (fail)
-  {
-  delete wf;
-  return 0;
-  }
-return wf;
+  byebye:
+    if (fail)
+    {
+	delete wf;
+	return 0;
+    }
+    return wf;
 }
 
 
 /*
  *	ListMasterDirectory - list the master directory
  */
-void ListMasterDirectory (FILE *file)
+void ListMasterDirectory(FILE * file)
 {
-char dataname[WAD_NAME + 1];
-MDirPtr dir;
-char key;
-int lines = 3;
+    char dataname[WAD_NAME + 1];
+    MDirPtr dir;
+    char key;
+    int lines = 3;
 
-dataname[WAD_NAME] = '\0';
-fprintf (file, "The Master Directory\n");
-fprintf (file, "====================\n\n");
-fprintf (file, "NAME____  FILE______________________________________________"
-   "  SIZE__  START____\n");
-for (dir = MasterDir; dir; dir = dir->next)
-   {
-   strncpy (dataname, dir->dir.name, WAD_NAME);
-   fprintf (file, "%-*s  %-50s  %6ld  x%08lx\n",
-    WAD_NAME, dataname, dir->wadfile->pathname (),
-    dir->dir.size, dir->dir.start);
-   if (file == stdout && lines++ > screen_lines - 4)
-      {
-      lines = 0;
-      printf ("['Q' followed by Return to abort, Return only to continue]");
-      key = getchar ();
-      printf ("\r%57s\r", "");
-      if (key == 'Q' || key == 'q')
-	 {
-         getchar ();  // Read the '\n'
-         break;
-         }
-      }
-   }
+    dataname[WAD_NAME] = '\0';
+    fprintf(file, "The Master Directory\n");
+    fprintf(file, "====================\n\n");
+    fprintf(file,
+	    "NAME____  FILE______________________________________________"
+	    "  SIZE__  START____\n");
+    for (dir = MasterDir; dir; dir = dir->next)
+    {
+	strncpy(dataname, dir->dir.name, WAD_NAME);
+	fprintf(file, "%-*s  %-50s  %6ld  x%08lx\n",
+		WAD_NAME, dataname, dir->wadfile->pathname(),
+		dir->dir.size, dir->dir.start);
+	if (file == stdout && lines++ > screen_lines - 4)
+	{
+	    lines = 0;
+	    printf
+		("['Q' followed by Return to abort, Return only to continue]");
+	    key = getchar();
+	    printf("\r%57s\r", "");
+	    if (key == 'Q' || key == 'q')
+	    {
+		getchar();	// Read the '\n'
+		break;
+	    }
+	}
+    }
 }
 
 
 /*
  *	ListFileDirectory - list the directory of a wad
  */
-void ListFileDirectory (FILE *file, const Wad_file *wad)
+void ListFileDirectory(FILE * file, const Wad_file * wad)
 {
-char dataname[WAD_NAME + 1];
-char key;
-int lines = 5;
-long n;
+    char dataname[WAD_NAME + 1];
+    char key;
+    int lines = 5;
+    long n;
 
-dataname[WAD_NAME] = '\0';
-fprintf (file, "Wad File Directory\n");
-fprintf (file, "==================\n\n");
-fprintf (file, "Wad File: %s\n\n", wad->pathname ());
-fprintf (file, "NAME____  SIZE__  START____  END______\n");
-for (n = 0; n < wad->dirsize; n++)
-   {
-   strncpy (dataname, wad->directory[n].name, WAD_NAME);
-   fprintf (file, "%-*s  %6ld  x%08lx  x%08lx\n",
-     WAD_NAME, dataname,
-     wad->directory[n].size,
-     wad->directory[n].start,
-     wad->directory[n].size + wad->directory[n].start - 1);
-   if (file == stdout && lines++ > screen_lines - 4)
-      {
-      lines = 0;
-      printf ("['Q' followed by Return to abort, Return only to continue]");
-      key = getchar ();
-      printf ("\r%57s\r", "");
-      if (key == 'Q' || key == 'q')
-         {
-         getchar ();  // Read the '\n'
-	 break;
-         }
-      }
-   }
+    dataname[WAD_NAME] = '\0';
+    fprintf(file, "Wad File Directory\n");
+    fprintf(file, "==================\n\n");
+    fprintf(file, "Wad File: %s\n\n", wad->pathname());
+    fprintf(file, "NAME____  SIZE__  START____  END______\n");
+    for (n = 0; n < wad->dirsize; n++)
+    {
+	strncpy(dataname, wad->directory[n].name, WAD_NAME);
+	fprintf(file, "%-*s  %6ld  x%08lx  x%08lx\n",
+		WAD_NAME, dataname,
+		wad->directory[n].size,
+		wad->directory[n].start,
+		wad->directory[n].size + wad->directory[n].start - 1);
+	if (file == stdout && lines++ > screen_lines - 4)
+	{
+	    lines = 0;
+	    printf
+		("['Q' followed by Return to abort, Return only to continue]");
+	    key = getchar();
+	    printf("\r%57s\r", "");
+	    if (key == 'Q' || key == 'q')
+	    {
+		getchar();	// Read the '\n'
+		break;
+	    }
+	}
+    }
 }
 
 
@@ -580,85 +596,84 @@
  *
  *	Build a new wad file from master directory.
  */
-void BuildNewMainWad (const char *filename, bool patchonly)
+void BuildNewMainWad(const char *filename, bool patchonly)
 {
-FILE *file;
-long counter = 12;
-MDirPtr cur;
-long size;
-long dirstart;
-long dirnum;
+    FILE *file;
+    long counter = 12;
+    MDirPtr cur;
+    long size;
+    long dirstart;
+    long dirnum;
 
 /* open the file and store signatures */
-if (patchonly)
-   printf ("Building a compound Patch Wad file \"%s\".\n", filename);
-else
-   printf ("Building a new Main Wad file \"%s\" (size approx 10 MB)\n",
-      filename);
-if (FindMasterDir (MasterDir, "E2M4") == NULL
- && FindMasterDir (MasterDir, "MAP01") == NULL
- && FindMasterDir (MasterDir, "MAP33") == NULL
- && strcmp (Game, "doom02")
- && strcmp (Game, "doom04")
- && strcmp (Game, "doom05")
- && strcmp (Game, "doompr"))
-   fatal_error ("You were warned: you are not allowed to do this.");
-if ((file = fopen (filename, "wb")) == NULL)
-   fatal_error ("unable to open file \"%s\"", filename);
-if (patchonly)
-   WriteBytes (file, "PWAD", 4);
-else
-   WriteBytes (file, "IWAD", 4);
-file_write_i32 (file, 0xdeadbeef);      /* put true value in later */
-file_write_i32 (file, 0xdeadbeef);      /* put true value in later */
+    if (patchonly)
+	printf("Building a compound Patch Wad file \"%s\".\n", filename);
+    else
+	printf("Building a new Main Wad file \"%s\" (size approx 10 MB)\n",
+	       filename);
+    if (FindMasterDir(MasterDir, "E2M4") == NULL
+	&& FindMasterDir(MasterDir, "MAP01") == NULL
+	&& FindMasterDir(MasterDir, "MAP33") == NULL
+	&& strcmp(Game, "doom02")
+	&& strcmp(Game, "doom04")
+	&& strcmp(Game, "doom05") && strcmp(Game, "doompr"))
+	fatal_error("You were warned: you are not allowed to do this.");
+    if ((file = fopen(filename, "wb")) == NULL)
+	fatal_error("unable to open file \"%s\"", filename);
+    if (patchonly)
+	WriteBytes(file, "PWAD", 4);
+    else
+	WriteBytes(file, "IWAD", 4);
+    file_write_i32(file, 0xdeadbeef);	/* put true value in later */
+    file_write_i32(file, 0xdeadbeef);	/* put true value in later */
 
 /* output the directory data chunks */
-const Wad_file *iwad = 0;	// FIXME unreliable way of knowing the iwad
-wad_list.rewind ();		// got to look into this
-wad_list.get (iwad);
-for (cur = MasterDir; cur; cur = cur->next)
-   {
-   if (patchonly && cur->wadfile == iwad)
-      continue;
-   size = cur->dir.size;
-   counter += size;
-   cur->wadfile->seek (cur->dir.start);
-   if (cur->wadfile->error ())
-      ;  // FIXME
-   if (copy_bytes (file, cur->wadfile->fp, size) != 0)
-      ;  // FIXME
-   printf ("Size: %luK\r", counter / 1024);
-   }
+    const Wad_file *iwad = 0;	// FIXME unreliable way of knowing the iwad
+    wad_list.rewind();		// got to look into this
+    wad_list.get(iwad);
+    for (cur = MasterDir; cur; cur = cur->next)
+    {
+	if (patchonly && cur->wadfile == iwad)
+	    continue;
+	size = cur->dir.size;
+	counter += size;
+	cur->wadfile->seek(cur->dir.start);
+	if (cur->wadfile->error())
+	    ;			// FIXME
+	if (copy_bytes(file, cur->wadfile->fp, size) != 0)
+	    ;			// FIXME
+	printf("Size: %luK\r", counter / 1024);
+    }
 
 /* output the directory */
-dirstart = counter;
-counter = 12;
-dirnum = 0;
-for (cur = MasterDir; cur; cur = cur->next)
-   {
-   if (patchonly && cur->wadfile == iwad)
-      continue;
-   if (dirnum % 100 == 0)
-      printf ("Outputting directory %04ld...\r", dirnum);
-   if (cur->dir.start)
-      file_write_i32 (file, counter);
-   else
-      file_write_i32 (file, 0);
-   file_write_i32 (file, cur->dir.size);
-   file_write_name (file, cur->dir.name);
-   counter += cur->dir.size;
-   dirnum++;
-   }
+    dirstart = counter;
+    counter = 12;
+    dirnum = 0;
+    for (cur = MasterDir; cur; cur = cur->next)
+    {
+	if (patchonly && cur->wadfile == iwad)
+	    continue;
+	if (dirnum % 100 == 0)
+	    printf("Outputting directory %04ld...\r", dirnum);
+	if (cur->dir.start)
+	    file_write_i32(file, counter);
+	else
+	    file_write_i32(file, 0);
+	file_write_i32(file, cur->dir.size);
+	file_write_name(file, cur->dir.name);
+	counter += cur->dir.size;
+	dirnum++;
+    }
 
 /* fix up the number of entries and directory start information */
-if (fseek (file, 4L, 0))
-   fatal_error ("error writing to file");
-file_write_i32 (file, dirnum);
-file_write_i32 (file, dirstart);
+    if (fseek(file, 4L, 0))
+	fatal_error("error writing to file");
+    file_write_i32(file, dirnum);
+    file_write_i32(file, dirstart);
 
 /* close the file */
-printf ("                            \r");
-fclose (file);
+    printf("                            \r");
+    fclose(file);
 }
 
 
@@ -667,85 +682,85 @@
  *
  *	Dump a directory entry in hex
  */
-void DumpDirectoryEntry (FILE *file, const char *entryname)
+void DumpDirectoryEntry(FILE * file, const char *entryname)
 {
-char dataname[WAD_NAME + 1];
-char key;
-int lines = 5;
-long n = 0;
-unsigned char buf[16];
-const int bytes_per_line = 16;
+    char dataname[WAD_NAME + 1];
+    char key;
+    int lines = 5;
+    long n = 0;
+    unsigned char buf[16];
+    const int bytes_per_line = 16;
 
-for (MDirPtr entry = MasterDir; entry != 0; entry = entry->next)
-   {
-   if (y_strnicmp (entry->dir.name, entryname, WAD_NAME) != 0)
-      continue;
-   strncpy (dataname, entry->dir.name, WAD_NAME);
-   dataname[WAD_NAME] = '\0';
-   fprintf (file, "Contents of entry %s (size = %ld bytes):\n",
-      dataname, entry->dir.size);
-   const Wad_file *wf = entry->wadfile;
-   wf->seek (entry->dir.start);
-   for (n = 0; n < entry->dir.size;)
-      {
-      int i;
-      fprintf (file, "%04lX: ", n);
+    for (MDirPtr entry = MasterDir; entry != 0; entry = entry->next)
+    {
+	if (y_strnicmp(entry->dir.name, entryname, WAD_NAME) != 0)
+	    continue;
+	strncpy(dataname, entry->dir.name, WAD_NAME);
+	dataname[WAD_NAME] = '\0';
+	fprintf(file, "Contents of entry %s (size = %ld bytes):\n",
+		dataname, entry->dir.size);
+	const Wad_file *wf = entry->wadfile;
+	wf->seek(entry->dir.start);
+	for (n = 0; n < entry->dir.size;)
+	{
+	    int i;
+	    fprintf(file, "%04lX: ", n);
 
-      // Nb of bytes to read for this line
-      long bytes_to_read = entry->dir.size - n;
-      if (bytes_to_read > bytes_per_line)
-	 bytes_to_read = bytes_per_line;
-      long nbytes = wf->read_vbytes (buf, bytes_to_read);
-      if (wf->error ())
-	 break;
-      n += nbytes;
+	    // Nb of bytes to read for this line
+	    long bytes_to_read = entry->dir.size - n;
+	    if (bytes_to_read > bytes_per_line)
+		bytes_to_read = bytes_per_line;
+	    long nbytes = wf->read_vbytes(buf, bytes_to_read);
+	    if (wf->error())
+		break;
+	    n += nbytes;
 
-      for (i = 0; i < nbytes; i++)
-	 fprintf (file, " %02X", buf[i]);
-      for (; i < bytes_per_line; i++)
-	 fputs ("   ", file);
-      fprintf (file, "   ");
+	    for (i = 0; i < nbytes; i++)
+		fprintf(file, " %02X", buf[i]);
+	    for (; i < bytes_per_line; i++)
+		fputs("   ", file);
+	    fprintf(file, "   ");
 
-      for (i = 0; i < nbytes; i++)
-	 {
-	 if (buf[i] >= 0x20
-	    && buf[i] != 0x7f
+	    for (i = 0; i < nbytes; i++)
+	    {
+		if (buf[i] >= 0x20 && buf[i] != 0x7f
 #ifdef Y_UNIX
-	    && ! (buf[i] >= 0x80 && buf[i] <= 0xa0)  // ISO 8859-1
+		    && !(buf[i] >= 0x80 && buf[i] <= 0xa0)	// ISO 8859-1
 #endif
-	    )
-	    putc (buf[i], file);
-	 else
-	    putc ('.', file);
-	 }
-      putc ('\n', file);
+		    )
+		    putc(buf[i], file);
+		else
+		    putc('.', file);
+	    }
+	    putc('\n', file);
 
-      if (file == stdout && lines++ > screen_lines - 4)
-	 {
-	 lines = 0;
-	 printf ("[%d%% - Q + Return to abort,"
-	     " S + Return to skip this entry,"
-	     " Return to continue]", (int) (n * 100 / entry->dir.size));
-	 key = getchar ();
-	 printf ("\r%68s\r", "");
-	 if (key == 'S' || key == 's')
+	    if (file == stdout && lines++ > screen_lines - 4)
 	    {
-	    getchar ();  // Read the '\n'
-	    break;
+		lines = 0;
+		printf("[%d%% - Q + Return to abort,"
+		       " S + Return to skip this entry,"
+		       " Return to continue]",
+		       (int) (n * 100 / entry->dir.size));
+		key = getchar();
+		printf("\r%68s\r", "");
+		if (key == 'S' || key == 's')
+		{
+		    getchar();	// Read the '\n'
+		    break;
+		}
+		if (key == 'Q' || key == 'q')
+		{
+		    getchar();	// Read the '\n'
+		    return;
+		}
 	    }
-	 if (key == 'Q' || key == 'q')
-	    {
-	    getchar ();  // Read the '\n'
-	    return;
-	    }
-	 }
-      }
-   }
-if (! n)
-   {
-   printf ("Entry not in master directory.\n");
-   return;
-   }
+	}
+    }
+    if (!n)
+    {
+	printf("Entry not in master directory.\n");
+	return;
+    }
 }
 
 
@@ -755,49 +770,49 @@
  *
  *	Save a directory entry to disk
  */
-void SaveDirectoryEntry (FILE *file, const char *entryname)
+void SaveDirectoryEntry(FILE * file, const char *entryname)
 {
-MDirPtr entry;
+    MDirPtr entry;
 
-for (entry = MasterDir; entry; entry = entry->next)
-   if (!y_strnicmp (entry->dir.name, entryname, WAD_NAME))
-      break;
-if (entry)
-   {
-   // Write the header
-   WriteBytes (file, "PWAD", 4);	// Type = PWAD
-   file_write_i32 (file, 1);		// 1 entry in the directory
-   file_write_i32 (file, 12);		// The directory starts at offset 12
+    for (entry = MasterDir; entry; entry = entry->next)
+	if (!y_strnicmp(entry->dir.name, entryname, WAD_NAME))
+	    break;
+    if (entry)
+    {
+	// Write the header
+	WriteBytes(file, "PWAD", 4);	// Type = PWAD
+	file_write_i32(file, 1);	// 1 entry in the directory
+	file_write_i32(file, 12);	// The directory starts at offset 12
 
-   // Write the directory
-   file_write_i32 (file, 28);		// First entry starts at offset 28
-   file_write_i32 (file, entry->dir.size);	// Size of first entry
-   file_write_name (file, entry->dir.name);	// Name of first entry
+	// Write the directory
+	file_write_i32(file, 28);	// First entry starts at offset 28
+	file_write_i32(file, entry->dir.size);	// Size of first entry
+	file_write_name(file, entry->dir.name);	// Name of first entry
 
-   // Write the lump data
-   entry->wadfile->seek (entry->dir.start);
-   if (entry->wadfile->error ())
-      {
-      err ("%s: seek error", entryname);
-      return;
-      }
-   int r = copy_bytes (file, entry->wadfile->fp, entry->dir.size);
-   if (r != 0)
-      {
-      if (r == 1)
-	err ("%s: error reading from source wad", entryname);
-      else if (r == 2)
-	err ("%s: error writing to destination wad", entryname);
-      else
-	nf_bug ("%s: copy_bytes() returned %d", entryname, r);
-      return;
-      }
-   }
-else
-   {
-   printf ("Entry not in master directory.\n");
-   return;
-   }
+	// Write the lump data
+	entry->wadfile->seek(entry->dir.start);
+	if (entry->wadfile->error())
+	{
+	    err("%s: seek error", entryname);
+	    return;
+	}
+	int r = copy_bytes(file, entry->wadfile->fp, entry->dir.size);
+	if (r != 0)
+	{
+	    if (r == 1)
+		err("%s: error reading from source wad", entryname);
+	    else if (r == 2)
+		err("%s: error writing to destination wad", entryname);
+	    else
+		nf_bug("%s: copy_bytes() returned %d", entryname, r);
+	    return;
+	}
+    }
+    else
+    {
+	printf("Entry not in master directory.\n");
+	return;
+    }
 }
 
 
@@ -806,40 +821,40 @@
  *
  *	Save a directory entry to disk, without a pwad header
  */
-void SaveEntryToRawFile (FILE *file, const char *entryname)
+void SaveEntryToRawFile(FILE * file, const char *entryname)
 {
-MDirPtr entry;
+    MDirPtr entry;
 
-for (entry = MasterDir; entry; entry = entry->next)
-   if (!y_strnicmp (entry->dir.name, entryname, WAD_NAME))
-      break;
-if (entry)
-   {
-   verbmsg ("Writing %ld bytes starting from offset %lX...\n",
-      (long) entry->dir.size, (unsigned long) entry->dir.start);
-   entry->wadfile->seek (entry->dir.start);
-   if (entry->wadfile->error ())
-      {
-      err ("%s: seek error", entryname);
-      return;
-      }
-   int r = copy_bytes (file, entry->wadfile->fp, entry->dir.size);
-   if (r != 0)
-      {
-      if (r == 1)
-	err ("%s: error reading from source wad", entryname);
-      else if (r == 2)
-	err ("%s: error writing to destination file", entryname);
-      else
-	nf_bug ("%s: copy_bytes() returned %d", entryname, r);
-      return;
-      }
-   }
-else
-   {
-   printf ("[Entry not in master directory]\n");
-   return;
-   }
+    for (entry = MasterDir; entry; entry = entry->next)
+	if (!y_strnicmp(entry->dir.name, entryname, WAD_NAME))
+	    break;
+    if (entry)
+    {
+	verbmsg("Writing %ld bytes starting from offset %lX...\n",
+		(long) entry->dir.size, (unsigned long) entry->dir.start);
+	entry->wadfile->seek(entry->dir.start);
+	if (entry->wadfile->error())
+	{
+	    err("%s: seek error", entryname);
+	    return;
+	}
+	int r = copy_bytes(file, entry->wadfile->fp, entry->dir.size);
+	if (r != 0)
+	{
+	    if (r == 1)
+		err("%s: error reading from source wad", entryname);
+	    else if (r == 2)
+		err("%s: error writing to destination file", entryname);
+	    else
+		nf_bug("%s: copy_bytes() returned %d", entryname, r);
+	    return;
+	}
+    }
+    else
+    {
+	printf("[Entry not in master directory]\n");
+	return;
+    }
 }
 
 
@@ -848,44 +863,44 @@
  *
  *	Encapsulate a raw file in a pwad file
  */
-void SaveEntryFromRawFile (FILE *file, FILE *raw, const char *entryname)
+void SaveEntryFromRawFile(FILE * file, FILE * raw, const char *entryname)
 {
-long    size;
-char    name8[WAD_NAME];
+    long size;
+    char name8[WAD_NAME];
 
 // Write the header
-WriteBytes (file, "PWAD", 4);		// Type = PWAD
-file_write_i32 (file, 1);		// 1 entry in the directory
-file_write_i32 (file, 12);		// The directory starts at offset 12
+    WriteBytes(file, "PWAD", 4);	// Type = PWAD
+    file_write_i32(file, 1);	// 1 entry in the directory
+    file_write_i32(file, 12);	// The directory starts at offset 12
 
 // Write the directory
-file_write_i32 (file, 28);		// First entry starts at offset 28
+    file_write_i32(file, 28);	// First entry starts at offset 28
 
-if (fseek (raw, 0L, SEEK_END) != 0)
-   fatal_error ("error reading from raw file");
-size = ftell (raw);
-if (size < 0)
-   fatal_error ("error reading from raw file");
-if (fseek (raw, 0L, SEEK_SET) != 0)
-   fatal_error ("error reading from raw file");
-file_write_i32 (file, size);		// Size of first entry
+    if (fseek(raw, 0L, SEEK_END) != 0)
+	fatal_error("error reading from raw file");
+    size = ftell(raw);
+    if (size < 0)
+	fatal_error("error reading from raw file");
+    if (fseek(raw, 0L, SEEK_SET) != 0)
+	fatal_error("error reading from raw file");
+    file_write_i32(file, size);	// Size of first entry
 
-memset (name8, '\0', WAD_NAME);
-strncpy (name8, entryname, WAD_NAME);
-file_write_name (file, name8);		// Name of first entry
+    memset(name8, '\0', WAD_NAME);
+    strncpy(name8, entryname, WAD_NAME);
+    file_write_name(file, name8);	// Name of first entry
 
 // Write the lump data
-int r = copy_bytes (file, raw, size);
-if (r != 0)
-   {
-   if (r == 1)
-     err ("%s: error reading from source file", entryname);
-   else if (r == 2)
-     err ("%s: error writing to destination wad", entryname);
-   else
-     nf_bug ("%s: copy_bytes() returned %d", entryname, r);
-   return;
-   }
+    int r = copy_bytes(file, raw, size);
+    if (r != 0)
+    {
+	if (r == 1)
+	    err("%s: error reading from source file", entryname);
+	else if (r == 2)
+	    err("%s: error writing to destination wad", entryname);
+	else
+	    nf_bug("%s: copy_bytes() returned %d", entryname, r);
+	return;
+    }
 }
 
 
@@ -899,79 +914,78 @@
 
 
 /* Directories that are searched for PWADs */
-static const char *standard_directories[] =
-   {
-   "",
-   "~/",                            // "~" means "the user's home directory"
-   "/usr/local/share/games/%s/",    // %s is replaced by <Game>
-   "/usr/share/games/%s/",          // %s is replaced by <Game>
-   "/usr/local/share/games/wads/",
-   "/usr/share/games/wads/",
-   0
-   };
+static const char *standard_directories[] = {
+    "",
+    "~/",			// "~" means "the user's home directory"
+    "/usr/local/share/games/%s/",	// %s is replaced by <Game>
+    "/usr/share/games/%s/",	// %s is replaced by <Game>
+    "/usr/local/share/games/wads/",
+    "/usr/share/games/wads/",
+    0
+};
 
 
-static char *locate_pwad (const char *filename)
+static char *locate_pwad(const char *filename)
 {
-al_fext_t ext;
-const char **dirname;
-char *real_basename;
-char *real_name;
+    al_fext_t ext;
+    const char **dirname;
+    char *real_basename;
+    char *real_name;
 
 // Get the extension in <ext>
-al_fana (filename, NULL, NULL, NULL, ext);
+    al_fana(filename, NULL, NULL, NULL, ext);
 
 // If it's an absolute name, stop there.
-if (is_absolute (filename))
-   {
-   real_name = (char *) GetMemory (strlen (filename) + 1 + (*ext ? 0 : 4));
-   strcpy (real_name, filename);
-   if (! *ext)
-      strcat (real_name, ".wad");
-   bool r = file_exists (real_name);
-   if (! r)
-      {
-      FreeMemory (real_name);
-      return 0;
-      }
-   return real_name;
-   }
+    if (is_absolute(filename))
+    {
+	real_name = (char *) GetMemory(strlen(filename) + 1 + (*ext ? 0 : 4));
+	strcpy(real_name, filename);
+	if (!*ext)
+	    strcat(real_name, ".wad");
+	bool r = file_exists(real_name);
+	if (!r)
+	{
+	    FreeMemory(real_name);
+	    return 0;
+	}
+	return real_name;
+    }
 
 // It's a relative name. If no extension given, append ".wad"
-real_basename = (char *) GetMemory (strlen (filename) + 1 + (*ext ? 0 : 4));
-strcpy (real_basename, filename);
-if (! *ext)
-   strcat (real_basename, ".wad");
+    real_basename = (char *) GetMemory(strlen(filename) + 1 + (*ext ? 0 : 4));
+    strcpy(real_basename, filename);
+    if (!*ext)
+	strcat(real_basename, ".wad");
 
 // Then search for a file of that name in the standard directories.
-real_name = (char *) GetMemory (Y_FILE_NAME + 1);
-for (dirname = standard_directories; *dirname; dirname++)
-   {
-   if (! strcmp (*dirname, "~/"))
-      if (getenv ("HOME"))
-         {
-	 al_scps (real_name, getenv ("HOME"), Y_FILE_NAME);
-         al_sapc (real_name, '/', Y_FILE_NAME);
-         }
-      else
-	 continue;
-   else
-      y_snprintf (real_name, Y_FILE_NAME + 1, *dirname, Game ? Game : "");
-   al_saps (real_name, real_basename, Y_FILE_NAME);
-   verbmsg ("  Trying \"%s\"... ", real_name);
-   if (file_exists (real_name))
-      {
-      verbmsg ("right on !\n");
-      FreeMemory (real_basename);
-      return real_name;
-      }
-   verbmsg ("nuts\n");
-   }
-FreeMemory (real_name);
-FreeMemory (real_basename);
-return NULL;
+    real_name = (char *) GetMemory(Y_FILE_NAME + 1);
+    for (dirname = standard_directories; *dirname; dirname++)
+    {
+	if (!strcmp(*dirname, "~/"))
+	    if (getenv("HOME"))
+	    {
+		al_scps(real_name, getenv("HOME"), Y_FILE_NAME);
+		al_sapc(real_name, '/', Y_FILE_NAME);
+	    }
+	    else
+		continue;
+	else
+	    y_snprintf(real_name, Y_FILE_NAME + 1, *dirname,
+		       Game ? Game : "");
+	al_saps(real_name, real_basename, Y_FILE_NAME);
+	verbmsg("  Trying \"%s\"... ", real_name);
+	if (file_exists(real_name))
+	{
+	    verbmsg("right on !\n");
+	    FreeMemory(real_basename);
+	    return real_name;
+	}
+	verbmsg("nuts\n");
+    }
+    FreeMemory(real_name);
+    FreeMemory(real_basename);
+    return NULL;
 }
 
 
 /* end of file */
-
--- a/src/wads2.h	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/wads2.h	Sat Sep 24 14:16:04 2011 +0300
@@ -5,25 +5,25 @@
  */
 
 
-#ifndef YH_WADS2  /* DO NOT INSERT ANYTHING BEFORE THIS LINE */
+#ifndef YH_WADS2		/* DO NOT INSERT ANYTHING BEFORE THIS LINE */
 #define YH_WADS2
 
 
 class Wad_file;
 
 
-int OpenMainWad (const char *);
-int OpenPatchWad (const char *);
-void CloseWadFiles (void);
-void CloseUnusedWadFiles (void);
-Wad_file *BasicWadOpen (const char *, ygpf_t pic_format);
-void ListMasterDirectory (FILE *);
-void ListFileDirectory (FILE *, const Wad_file *);
-void BuildNewMainWad (const char *, bool);
-void DumpDirectoryEntry (FILE *, const char *);
-void SaveDirectoryEntry (FILE *, const char *);
-void SaveEntryToRawFile (FILE *, const char *);
-void SaveEntryFromRawFile (FILE *, FILE *, const char *);
+int OpenMainWad(const char *);
+int OpenPatchWad(const char *);
+void CloseWadFiles(void);
+void CloseUnusedWadFiles(void);
+Wad_file *BasicWadOpen(const char *, ygpf_t pic_format);
+void ListMasterDirectory(FILE *);
+void ListFileDirectory(FILE *, const Wad_file *);
+void BuildNewMainWad(const char *, bool);
+void DumpDirectoryEntry(FILE *, const char *);
+void SaveDirectoryEntry(FILE *, const char *);
+void SaveEntryToRawFile(FILE *, const char *);
+void SaveEntryFromRawFile(FILE *, FILE *, const char *);
 
 
-#endif  /* DO NOT ADD ANYTHING AFTER THIS LINE */
+#endif /* DO NOT ADD ANYTHING AFTER THIS LINE */
--- a/src/warn.cc	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/warn.cc	Sat Sep 24 14:16:04 2011 +0300
@@ -37,17 +37,15 @@
  *	end with a '\n', do not prepend the "Warning: " string.
  *
  */
-void warn (const char *fmt, ...)
+void warn(const char *fmt, ...)
 {
-  static bool start_of_line = true;
-  va_list args;
+    static bool start_of_line = true;
+    va_list args;
 
-  if (start_of_line)
-    fputs ("Warning: ", stdout);
-  va_start (args, fmt);
-  vprintf (fmt, args);
-  size_t len = strlen (fmt);
-  start_of_line = len > 0 && fmt[len - 1] == '\n';
+    if (start_of_line)
+	fputs("Warning: ", stdout);
+    va_start(args, fmt);
+    vprintf(fmt, args);
+    size_t len = strlen(fmt);
+    start_of_line = len > 0 && fmt[len - 1] == '\n';
 }
-
-
--- a/src/windim.cc	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/windim.cc	Sat Sep 24 14:16:04 2011 +0300
@@ -36,77 +36,76 @@
 // Holds the private data members.
 struct Win_dim_priv
 {
-  int value;
-  bool relative;
+    int value;
+    bool relative;
 };
 
 
-Win_dim::Win_dim ()
+Win_dim::Win_dim()
 {
-  p           = new Win_dim_priv;
-  p->value    = 0;
-  p->relative = false;
+    p = new Win_dim_priv;
+    p->value = 0;
+    p->relative = false;
 }
 
 
-Win_dim::Win_dim (const char *string)
+Win_dim::Win_dim(const char *string)
 {
-  p           = new Win_dim_priv;
-  p->value    = 0;
-  p->relative = false;
-  set (string);
+    p = new Win_dim_priv;
+    p->value = 0;
+    p->relative = false;
+    set(string);
 }
 
 
-Win_dim::~Win_dim ()
+Win_dim::~Win_dim()
 {
-  delete p;
-  p = 0;
+    delete p;
+    p = 0;
 }
 
 
 // String -> Win_dim
-int Win_dim::set (const char *string)
+int Win_dim::set(const char *string)
 {
-  int  value    = 0;
-  bool relative = false;
+    int value = 0;
+    bool relative = false;
 
-  if (! isdigit (*string))
-    return 1;  // Error
-  while (isdigit (*string))
-  {
-    value = 10 * value + dectoi (*string);
-    string++;
-  }
-  if (*string == '%')
-  {
-    relative = true;
-    string++;
-  }
-  if (*string != '\0')
-    return 1;  // Error
-  p->value    = value;
-  p->relative = relative;
-  return 0;
+    if (!isdigit(*string))
+	return 1;		// Error
+    while (isdigit(*string))
+    {
+	value = 10 * value + dectoi(*string);
+	string++;
+    }
+    if (*string == '%')
+    {
+	relative = true;
+	string++;
+    }
+    if (*string != '\0')
+	return 1;		// Error
+    p->value = value;
+    p->relative = relative;
+    return 0;
 }
 
 
 // Get numeric value
-int Win_dim::pixels (int ref_pixels)
+int Win_dim::pixels(int ref_pixels)
 {
-  if (p->relative)
-    return ref_pixels * p->value / 100;
-  else
-    return p->value;
+    if (p->relative)
+	return ref_pixels * p->value / 100;
+    else
+	return p->value;
 }
 
 
 // Win_dim -> string
-void Win_dim::string (char *buf, size_t buf_size)
+void Win_dim::string(char *buf, size_t buf_size)
 {
-  if (p->relative)
-    y_snprintf (buf, buf_size, "%d%%", p->value);
-  else
-    y_snprintf (buf, buf_size, "%d", p->value);
+    if (p->relative)
+	y_snprintf(buf, buf_size, "%d%%", p->value);
+    else
+	y_snprintf(buf, buf_size, "%d", p->value);
 }
-
--- a/src/windim.h	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/windim.h	Sat Sep 24 14:16:04 2011 +0300
@@ -5,7 +5,7 @@
  */
 
 
-#ifndef YH_WINDIM  /* DO NOT INSERT ANYTHING BEFORE THIS LINE */
+#ifndef YH_WINDIM		/* DO NOT INSERT ANYTHING BEFORE THIS LINE */
 #define YH_WINDIM
 
 
@@ -13,18 +13,18 @@
 
 class Win_dim
 {
-   public:
-     Win_dim ();
-     Win_dim (const char *string);
-     ~Win_dim ();
-     int set (const char *string);
-     int pixels (int ref_pixels);
-     void string (char *buf, size_t buf_size);
+  public:
+    Win_dim();
+    Win_dim(const char *string);
+     ~Win_dim();
+    int set(const char *string);
+    int pixels(int ref_pixels);
+    void string(char *buf, size_t buf_size);
 
-   private:
-     Win_dim (const Win_dim&);			// Too lazy to implement it
-     Win_dim& operator= (const Win_dim&);	// Too lazy to implement it
-     struct Win_dim_priv* p;
+  private:
+      Win_dim(const Win_dim &);	// Too lazy to implement it
+      Win_dim & operator=(const Win_dim &);	// Too lazy to implement it
+    struct Win_dim_priv *p;
 };
 
-#endif  /* DO NOT ADD ANYTHING AFTER THIS LINE */
+#endif /* DO NOT ADD ANYTHING AFTER THIS LINE */
--- a/src/wstructs.h	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/wstructs.h	Sat Sep 24 14:16:04 2011 +0300
@@ -31,22 +31,22 @@
 */
 
 
-#ifndef YH_WSTRUCTS	// To prevent multiple inclusion
-#define YH_WSTRUCTS	// To prevent multiple inclusion
+#ifndef YH_WSTRUCTS		// To prevent multiple inclusion
+#define YH_WSTRUCTS		// To prevent multiple inclusion
 
 
 // FIXME: all identifiers should start with wad_ or WAD_...
 
 
 // Directory
-const size_t WAD_NAME = 8;		// Length of a directory entry name
+const size_t WAD_NAME = 8;	// Length of a directory entry name
 typedef char wad_name_t[WAD_NAME];
 typedef struct Directory *DirPtr;
 struct Directory
 {
-  i32        start;			// Offset to start of data
-  i32        size;			// Byte size of data
-  wad_name_t name;			// Name of data block
+    i32 start;			// Offset to start of data
+    i32 size;			// Byte size of data
+    wad_name_t name;		// Name of data block
 };
 
 
@@ -66,77 +66,77 @@
 
 
 // Level objects properties
-typedef i16 wad_coord_t;		// Map (X,Y) coordinates
-typedef i16 wad_ldn_t;			// Linedef#
-typedef i16 wad_sdn_t;			// Sidedef#
-typedef i16 wad_sn_t;			// Sector#
-typedef i16 wad_tag_t;			// Tag
-typedef i16 wad_tn_t;			// Thing# (theor. there might be more)
-typedef i16 wad_vn_t;			// Vertex#
-typedef i16 wad_z_t;			// Map Z coordinate
+typedef i16 wad_coord_t;	// Map (X,Y) coordinates
+typedef i16 wad_ldn_t;		// Linedef#
+typedef i16 wad_sdn_t;		// Sidedef#
+typedef i16 wad_sn_t;		// Sector#
+typedef i16 wad_tag_t;		// Tag
+typedef i16 wad_tn_t;		// Thing# (theor. there might be more)
+typedef i16 wad_vn_t;		// Vertex#
+typedef i16 wad_z_t;		// Map Z coordinate
 
 
 // Things
-const size_t WAD_THING_BYTES       = 10;  // Size in the wad file
-const size_t WAD_HEXEN_THING_BYTES = 20;  // Size in the wad file
+const size_t WAD_THING_BYTES = 10;	// Size in the wad file
+const size_t WAD_HEXEN_THING_BYTES = 20;	// Size in the wad file
 typedef i16 wad_ttype_t;
 typedef i16 wad_tangle_t;
 typedef i16 wad_tflags_t;
 struct Thing
 {
-  wad_coord_t      xpos;		// FIXME rename to "x"
-  wad_coord_t      ypos;		// FIXME rename to "y"
-  wad_tangle_t     angle;
-  wad_ttype_t      type;
-  wad_tflags_t     when;		// FIXME rename to "flags"
+    wad_coord_t xpos;		// FIXME rename to "x"
+    wad_coord_t ypos;		// FIXME rename to "y"
+    wad_tangle_t angle;
+    wad_ttype_t type;
+    wad_tflags_t when;		// FIXME rename to "flags"
 };
 typedef struct
 {
-  i16              tid;
-  wad_coord_t      x;
-  wad_coord_t      y;
-  wad_z_t          height;
-  wad_tangle_t     angle;
-  wad_ttype_t      type;
-  i16              options;
-  u8               special;
-  u8               arg1;
-  u8               arg2;
-  u8               arg3;
-  u8               arg4;
-  u8               arg5;
+    i16 tid;
+    wad_coord_t x;
+    wad_coord_t y;
+    wad_z_t height;
+    wad_tangle_t angle;
+    wad_ttype_t type;
+    i16 options;
+    u8 special;
+    u8 arg1;
+    u8 arg2;
+    u8 arg3;
+    u8 arg4;
+    u8 arg5;
 } wad_hexen_thing_t;
 typedef struct Thing *TPtr;
 
 
 // Linedefs
-const size_t WAD_LINEDEF_BYTES       = 14;  // Size in the wad file
-const size_t WAD_HEXEN_LINEDEF_BYTES = 16;  // Size in the wad file
+const size_t WAD_LINEDEF_BYTES = 14;	// Size in the wad file
+const size_t WAD_HEXEN_LINEDEF_BYTES = 16;	// Size in the wad file
 typedef i16 wad_ldflags_t;
 typedef i16 wad_ldtype_t;
 struct LineDef
 {
-  wad_vn_t      start;			// # of start vertex
-  wad_vn_t      end;			// # of end vertex
-  wad_ldflags_t flags;
-  wad_ldtype_t  type;
-  wad_tag_t     tag;
-  wad_sdn_t     sidedef1;		// # of first (right) sidedef
-  wad_sdn_t     sidedef2;		// # of second (left) sidedef or 0xffff
+    wad_vn_t start;		// # of start vertex
+    wad_vn_t end;		// # of end vertex
+    wad_ldflags_t flags;
+    wad_ldtype_t type;
+    wad_tag_t tag;
+    wad_sdn_t sidedef1;		// # of first (right) sidedef
+    wad_sdn_t sidedef2;		// # of second (left) sidedef or 0xffff
 };
 typedef struct
 {
-  wad_vn_t      start;
-  wad_vn_t      end;
-  wad_ldflags_t flags;
-  u8            type;
-  u8            arg1;
-  u8            arg2;
-  u8            arg3;
-  u8            arg4;
-  u8            arg5;
-  wad_sdn_t     sidedef1;
-  wad_sdn_t     sidedef2;
+    wad_vn_t start;
+    wad_vn_t end;
+    wad_ldflags_t flags;
+    u8 type;
+    u8 arg1;
+    u8 arg2;
+    u8 arg3;
+    u8 arg4;
+    u8 arg5;
+    wad_sdn_t sidedef1;
+    wad_sdn_t sidedef2;
 } wad_hexen_linedef_t;
 typedef struct LineDef *LDPtr;
 
@@ -145,12 +145,12 @@
 const size_t WAD_SIDEDEF_BYTES = 30;	// Size in the wad file
 struct SideDef
 {
-  wad_coord_t    xoff;			// FIXME rename to "xofs"
-  wad_coord_t    yoff;			// FIXME rename to "yofs"
-  wad_tex_name_t tex1;			// Name of upper texture
-  wad_tex_name_t tex2;			// Name of lower texture
-  wad_tex_name_t tex3;			// Name of middle texture
-  wad_sn_t       sector;		// # of adjacent sector
+    wad_coord_t xoff;		// FIXME rename to "xofs"
+    wad_coord_t yoff;		// FIXME rename to "yofs"
+    wad_tex_name_t tex1;	// Name of upper texture
+    wad_tex_name_t tex2;	// Name of lower texture
+    wad_tex_name_t tex3;	// Name of middle texture
+    wad_sn_t sector;		// # of adjacent sector
 };
 // (it's the same for Hexen)
 typedef struct SideDef *SDPtr;
@@ -160,8 +160,8 @@
 const size_t WAD_VERTEX_BYTES = 4;	// Size in the wad file
 struct Vertex
 {
-  wad_coord_t x;
-  wad_coord_t y;
+    wad_coord_t x;
+    wad_coord_t y;
 };
 // (it's the same for Hexen)
 typedef struct Vertex *VPtr;
@@ -172,13 +172,13 @@
 typedef i16 wad_stype_t;
 struct Sector
 {
-  wad_z_t         floorh;		// Floor height
-  wad_z_t         ceilh;		// Ceiling height
-  wad_flat_name_t floort;		// Name of floor texture
-  wad_flat_name_t ceilt;		// Name of ceiling texture
-  i16             light;		// Light level (0-255)
-  wad_stype_t     special;		// FIXME rename to "type"
-  wad_tag_t       tag;
+    wad_z_t floorh;		// Floor height
+    wad_z_t ceilh;		// Ceiling height
+    wad_flat_name_t floort;	// Name of floor texture
+    wad_flat_name_t ceilt;	// Name of ceiling texture
+    i16 light;			// Light level (0-255)
+    wad_stype_t special;	// FIXME rename to "type"
+    wad_tag_t tag;
 };
 typedef struct Sector *SPtr;
 
@@ -186,42 +186,41 @@
 // The 11 lumps that constitute a Doom/Heretic/Strife level
 typedef enum
 {
-  WAD_LL_LABEL,
-  WAD_LL_THINGS,
-  WAD_LL_LINEDEFS,
-  WAD_LL_SIDEDEFS,
-  WAD_LL_VERTEXES,
-  WAD_LL_SEGS,
-  WAD_LL_SSECTORS,
-  WAD_LL_NODES,
-  WAD_LL_SECTORS,
-  WAD_LL_REJECT,
-  WAD_LL_BLOCKMAP,
-		      // Hexen has a BEHAVIOR lump here
-  WAD_LL__
+    WAD_LL_LABEL,
+    WAD_LL_THINGS,
+    WAD_LL_LINEDEFS,
+    WAD_LL_SIDEDEFS,
+    WAD_LL_VERTEXES,
+    WAD_LL_SEGS,
+    WAD_LL_SSECTORS,
+    WAD_LL_NODES,
+    WAD_LL_SECTORS,
+    WAD_LL_REJECT,
+    WAD_LL_BLOCKMAP,
+    // Hexen has a BEHAVIOR lump here
+    WAD_LL__
 } wad_level_lump_no_t;
 
 typedef struct
 {
-  const char *const name;
-  size_t item_size;
+    const char *const name;
+    size_t item_size;
 } wad_level_lump_def_t;
 
-const wad_level_lump_def_t wad_level_lump[WAD_LL__] =
-{
-  { 0,          0                 },  // Label -- no fixed name
-  { "THINGS",   WAD_THING_BYTES   },
-  { "LINEDEFS", WAD_LINEDEF_BYTES },
-  { "SIDEDEFS", WAD_SIDEDEF_BYTES },
-  { "VERTEXES", WAD_VERTEX_BYTES  },
-  { "SEGS",     0                 },
-  { "SSECTORS", 0                 },
-  { "NODES",    0                 },
-  { "SECTORS",  WAD_SECTOR_BYTES  },
-  { "REJECT",   0                 },
-  { "BLOCKMAP", 0                 }
-				      // Hexen has a BEHAVIOR lump here
+const wad_level_lump_def_t wad_level_lump[WAD_LL__] = {
+    { NULL,          0 },  // Label -- no fixed name
+    { "THINGS",      WAD_THING_BYTES },
+    { "LINEDEFS",    WAD_LINEDEF_BYTES },
+    { "SIDEDEFS",    WAD_SIDEDEF_BYTES },
+    { "VERTEXES",    WAD_VERTEX_BYTES },
+    { "SEGS",        0 },
+    { "SSECTORS",    0 },
+    { "NODES",       0 },
+    { "SECTORS",     WAD_SECTOR_BYTES },
+    { "REJECT",      0 },
+    { "BLOCKMAP",    0 }
+    // Hexen has a BEHAVIOR lump here
 };
 
 
-#endif  /* DO NOT ADD ANYTHING AFTER THIS LINE */
+#endif /* DO NOT ADD ANYTHING AFTER THIS LINE */
--- a/src/x11.cc	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/x11.cc	Sat Sep 24 14:16:04 2011 +0300
@@ -44,12 +44,12 @@
  *	x_bell
  *	Ring the bell
  */
-void x_bell ()
+void x_bell()
 {
-  if (dpy)
-    XBell (dpy, 0);
-  else
-    nf_bug ("x_bell: not connected");
+    if (dpy)
+	XBell(dpy, 0);
+    else
+	nf_bug("x_bell: not connected");
 }
 
 
@@ -60,11 +60,11 @@
  *	default handler (that has the annoying property of
  *	calling exit()).
  */
-void x_catch_on ()
+void x_catch_on()
 {
-  XSetErrorHandler (x_error_handler);
-  XSynchronize (dpy, True);
-  x_clear_error ();
+    XSetErrorHandler(x_error_handler);
+    XSynchronize(dpy, True);
+    x_clear_error();
 }
 
 
@@ -72,10 +72,10 @@
  *	x_catch_off
  *	Restore the default error handler.
  */
-void x_catch_off ()
+void x_catch_off()
 {
-  XSynchronize (dpy, False);
-  XSetErrorHandler (0);
+    XSynchronize(dpy, False);
+    XSetErrorHandler(0);
 }
 
 
@@ -83,11 +83,11 @@
  *	x_error_handler
  *	An error handler that does not exit.
  */
-int x_error_handler (Display *dpy, XErrorEvent *e)
+int x_error_handler(Display * dpy, XErrorEvent * e)
 {
-  _have_error = true;
-  _error_code = e->error_code;  // We're only interested in the error code
-  return 0;
+    _have_error = true;
+    _error_code = e->error_code;	// We're only interested in the error code
+    return 0;
 }
 
 
@@ -96,9 +96,9 @@
  *	Call this before attempting an operation that might
  *	cause an error that you want to catch.
  */
-void x_clear_error ()
+void x_clear_error()
 {
-  _have_error = false;
+    _have_error = false;
 }
 
 
@@ -108,14 +108,14 @@
  *	or a NULL pointer if no error has occured since last
  *	call to x_clear_error().
  */
-const char *x_error ()
+const char *x_error()
 {
-  if (! _have_error)
-    return 0;
-  static char buf[100];
-  XGetErrorText (dpy, _error_code, buf, sizeof buf);
-  return buf;
+    if (!_have_error)
+	return 0;
+    static char buf[100];
+    XGetErrorText(dpy, _error_code, buf, sizeof buf);
+    return buf;
 }
 
 
-#endif  /* DO NOT ADD ANYTHING AFTER THIS LINE */
+#endif /* DO NOT ADD ANYTHING AFTER THIS LINE */
--- a/src/x11.h	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/x11.h	Sat Sep 24 14:16:04 2011 +0300
@@ -8,16 +8,16 @@
 /* Declarations that don't rely on the X11 headers */
 #if defined Y_X11 && ! defined Y_X11_H1
 #define Y_X11_H1
-void x_bell ();
-void x_catch_on ();
-void x_catch_off ();
-void x_clear_error ();
-const char *x_error ();
+void x_bell();
+void x_catch_on();
+void x_catch_off();
+void x_clear_error();
+const char *x_error();
 #endif
 
 
 /* Declarations that do */
 #if defined Y_X11 && defined X_PROTOCOL && ! defined Y_X11_H2
 #define Y_X11_H2
-int x_error_handler (Display *dpy, XErrorEvent *e);
+int x_error_handler(Display * dpy, XErrorEvent * e);
 #endif
--- a/src/x_centre.cc	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/x_centre.cc	Sat Sep 24 14:16:04 2011 +0300
@@ -42,24 +42,23 @@
  *	Return the coordinates of the centre of a group of objects
  *	of type <obj_type>.
  */
-void centre_of_objects (int obj_type, SelPtr list, int *x, int *y)
+void centre_of_objects(int obj_type, SelPtr list, int *x, int *y)
 {
-  switch (obj_type)
-  {
+    switch (obj_type)
+    {
     case OBJ_LINEDEFS:
-      centre_of_linedefs (list, x, y);
-      break;
+	centre_of_linedefs(list, x, y);
+	break;
     case OBJ_SECTORS:
-      centre_of_sectors (list, x, y);
-      break;
+	centre_of_sectors(list, x, y);
+	break;
     case OBJ_THINGS:
-      centre_of_things (list, x, y);
-      break;
+	centre_of_things(list, x, y);
+	break;
     case OBJ_VERTICES:
-      centre_of_vertices (list, x, y);
-      break;
+	centre_of_vertices(list, x, y);
+	break;
     default:
-      fatal_error ("coo: bad obj_type %d", obj_type);
-  }
+	fatal_error("coo: bad obj_type %d", obj_type);
+    }
 }
-
--- a/src/x_centre.h	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/x_centre.h	Sat Sep 24 14:16:04 2011 +0300
@@ -4,6 +4,4 @@
  */
 
 
-void centre_of_objects (int obj_type, SelPtr list, int *x, int *y);
-
-
+void centre_of_objects(int obj_type, SelPtr list, int *x, int *y);
--- a/src/x_exchng.cc	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/x_exchng.cc	Sat Sep 24 14:16:04 2011 +0300
@@ -41,72 +41,70 @@
  *
  *	Return 0 on success, non-zero on failure.
  */
-int exchange_objects_numbers (int obj_type, SelPtr list, bool adjust)
+int exchange_objects_numbers(int obj_type, SelPtr list, bool adjust)
 {
-  int n1, n2;
-
-  // Must have exactly two objects in the selection
-  if (list == 0 || list->next == 0 || (list->next)->next != 0)
-  {
-    nf_bug ("exchange_object_numbers: wrong objects count.");
-    return 1;
-  }
-  n1 = list->objnum;
-  n2 = (list->next)->objnum;
+    int n1, n2;
 
-  if (obj_type == OBJ_LINEDEFS)
-  {
-    struct LineDef swap_buf;
-    swap_buf = LineDefs[n1];
-    LineDefs[n1] = LineDefs[n2];
-    LineDefs[n2] = swap_buf;
-  }
-  else if (obj_type == OBJ_SECTORS)
-  {
-    struct Sector swap_buf;
-    swap_buf = Sectors[n1];
-    Sectors[n1] = Sectors[n2];
-    Sectors[n2] = swap_buf;
-    if (adjust)
+    // Must have exactly two objects in the selection
+    if (list == 0 || list->next == 0 || (list->next)->next != 0)
+    {
+	nf_bug("exchange_object_numbers: wrong objects count.");
+	return 1;
+    }
+    n1 = list->objnum;
+    n2 = (list->next)->objnum;
+
+    if (obj_type == OBJ_LINEDEFS)
+    {
+	struct LineDef swap_buf;
+	swap_buf = LineDefs[n1];
+	LineDefs[n1] = LineDefs[n2];
+	LineDefs[n2] = swap_buf;
+    }
+    else if (obj_type == OBJ_SECTORS)
     {
-      for (int n = 0; n < NumSideDefs; n++)
-      {
-	if (SideDefs[n].sector == n1)
-	  SideDefs[n].sector = n2;
-	else if (SideDefs[n].sector == n2)
-	  SideDefs[n].sector = n1;
-      }
+	struct Sector swap_buf;
+	swap_buf = Sectors[n1];
+	Sectors[n1] = Sectors[n2];
+	Sectors[n2] = swap_buf;
+	if (adjust)
+	{
+	    for (int n = 0; n < NumSideDefs; n++)
+	    {
+		if (SideDefs[n].sector == n1)
+		    SideDefs[n].sector = n2;
+		else if (SideDefs[n].sector == n2)
+		    SideDefs[n].sector = n1;
+	    }
+	}
+    }
+    else if (obj_type == OBJ_THINGS)
+    {
+	struct Thing swap_buf;
+	swap_buf = Things[n1];
+	Things[n1] = Things[n2];
+	Things[n2] = swap_buf;
     }
-  }
-  else if (obj_type == OBJ_THINGS)
-  {
-    struct Thing swap_buf;
-    swap_buf = Things[n1];
-    Things[n1] = Things[n2];
-    Things[n2] = swap_buf;
-  }
-  else if (obj_type == OBJ_VERTICES)
-  {
-    struct Vertex swap_buf;
-    swap_buf = Vertices[n1];
-    Vertices[n1] = Vertices[n2];
-    Vertices[n2] = swap_buf;
-    if (adjust)
+    else if (obj_type == OBJ_VERTICES)
     {
-      for (int n = 0; n < NumLineDefs; n++)
-      {
-	if (LineDefs[n].start == n1)
-	  LineDefs[n].start = n2;
-	else if (LineDefs[n].start == n2)
-	  LineDefs[n].start = n1;
-	if (LineDefs[n].end == n1)
-	  LineDefs[n].end = n2;
-	else if (LineDefs[n].end == n2)
-	  LineDefs[n].end = n1;
-      }
+	struct Vertex swap_buf;
+	swap_buf = Vertices[n1];
+	Vertices[n1] = Vertices[n2];
+	Vertices[n2] = swap_buf;
+	if (adjust)
+	{
+	    for (int n = 0; n < NumLineDefs; n++)
+	    {
+		if (LineDefs[n].start == n1)
+		    LineDefs[n].start = n2;
+		else if (LineDefs[n].start == n2)
+		    LineDefs[n].start = n1;
+		if (LineDefs[n].end == n1)
+		    LineDefs[n].end = n2;
+		else if (LineDefs[n].end == n2)
+		    LineDefs[n].end = n1;
+	    }
+	}
     }
-  }
-  return 0;
+    return 0;
 }
-
-
--- a/src/x_exchng.h	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/x_exchng.h	Sat Sep 24 14:16:04 2011 +0300
@@ -4,6 +4,4 @@
  */
 
 
-int exchange_objects_numbers (int obj_type, SelPtr list, bool adjust);
-
-
+int exchange_objects_numbers(int obj_type, SelPtr list, bool adjust);
--- a/src/x_hover.cc	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/x_hover.cc	Sat Sep 24 14:16:04 2011 +0300
@@ -39,58 +39,59 @@
 
 class Close_obj
 {
-  public :
-    Close_obj () { nil (); }
-    void nil ()
+    public:Close_obj()
     {
-      obj.nil ();
-      distance = ULONG_MAX;
-      radius   = INT_MAX;
-      inside   = false;
+	nil();
     }
-    bool operator== (const Close_obj& other) const
+    void nil()
     {
-      if (inside == other.inside
-	 && radius == other.radius
-	 && distance == other.distance)
-       return true;
-      return false;
+	obj.nil();
+	distance = ULONG_MAX;
+	radius = INT_MAX;
+	inside = false;
     }
-    bool operator< (const Close_obj& other) const
+    bool operator==(const Close_obj & other) const
     {
-      if (inside && ! other.inside)
-	return true;
-      if (! inside && other.inside)
+	if (inside == other.inside
+	    && radius == other.radius && distance == other.distance)
+	    return true;
 	return false;
+    }
+    bool operator<(const Close_obj & other) const
+    {
+	if (inside && !other.inside)
+	    return true;
+	if (!inside && other.inside)
+	    return false;
 
-      // Small objects should "mask" large objects
-      if (radius < other.radius)
-	return true;
-      if (radius > other.radius)
-	return false;
+	// Small objects should "mask" large objects
+	if (radius < other.radius)
+	    return true;
+	if (radius > other.radius)
+	    return false;
 
-      if (distance < other.distance)
-	return true;
-      if (distance > other.distance)
-	return false;
+	if (distance < other.distance)
+	    return true;
+	if (distance > other.distance)
+	    return false;
 
-      return radius < other.radius;
+	return radius < other.radius;
     }
-    bool operator<= (const Close_obj& other) const
+    bool operator<=(const Close_obj & other) const
     {
-      return *this == other || *this < other;
+	return *this == other || *this < other;
     }
-    Objid  obj;
+    Objid obj;
     double distance;
-    bool   inside;
-    int    radius;
+    bool inside;
+    int radius;
 };
 
 
-static const Close_obj& get_cur_linedef (int x, int y);
-static const Close_obj& get_cur_sector  (int x, int y);
-static const Close_obj& get_cur_thing   (int x, int y);
-static const Close_obj& get_cur_vertex  (int x, int y);
+static const Close_obj & get_cur_linedef(int x, int y);
+static const Close_obj & get_cur_sector(int x, int y);
+static const Close_obj & get_cur_thing(int x, int y);
+static const Close_obj & get_cur_vertex(int x, int y);
 
 
 /*
@@ -100,321 +101,313 @@
  *	coordinates (<x>, <y>). If several objects are close
  *	enough to the pointer, the smallest object is chosen.
  */
-void GetCurObject (Objid& o, int objtype, int x, int y)
+void GetCurObject(Objid & o, int objtype, int x, int y)
 {
-switch (objtype)
-   {
-   case OBJ_THINGS:
-     {
-       o = get_cur_thing (x, y).obj;
-       return;
-     }
+    switch (objtype)
+    {
+    case OBJ_THINGS:
+	{
+	    o = get_cur_thing(x, y).obj;
+	    return;
+	}
 
-   case OBJ_VERTICES:
-     {
-       o = get_cur_vertex (x, y).obj;
-       return;
-     }
+    case OBJ_VERTICES:
+	{
+	    o = get_cur_vertex(x, y).obj;
+	    return;
+	}
 
-   case OBJ_LINEDEFS:
-     {
-       o = get_cur_linedef (x, y).obj;
-       return;
-     }
+    case OBJ_LINEDEFS:
+	{
+	    o = get_cur_linedef(x, y).obj;
+	    return;
+	}
 
-   case OBJ_SECTORS:
-     {
-       o = get_cur_sector (x, y).obj;
-       return;
-     }
+    case OBJ_SECTORS:
+	{
+	    o = get_cur_sector(x, y).obj;
+	    return;
+	}
 
-   case OBJ_ANY:
-     {
-       std::vector<Close_obj> v;
-       v.push_back (get_cur_linedef (x, y));
-       v.push_back (get_cur_thing   (x, y));
-       v.push_back (get_cur_vertex  (x, y));
-       sort (v.begin (), v.end ());
-       if (v[0].obj ())
-       {
-	 o = v[0].obj;
-	 return;
-       }
-       o = get_cur_sector (x, y).obj;
-       return;
-     }
+    case OBJ_ANY:
+	{
+	    std::vector < Close_obj > v;
+	    v.push_back(get_cur_linedef(x, y));
+	    v.push_back(get_cur_thing(x, y));
+	    v.push_back(get_cur_vertex(x, y));
+	    sort(v.begin(), v.end());
+	    if (v[0].obj())
+	    {
+		o = v[0].obj;
+		return;
+	    }
+	    o = get_cur_sector(x, y).obj;
+	    return;
+	}
 
-   default:
-     nf_bug ("GetCurObject: objtype %d", (int) objtype);
-     o.nil ();
-     return;
-   }
+    default:
+	nf_bug("GetCurObject: objtype %d", (int) objtype);
+	o.nil();
+	return;
+    }
 }
 
 
 /*
  *	get_cur_linedef - determine which linedef is under the pointer
  */
-static const Close_obj& get_cur_linedef (int x, int y)
+static const Close_obj & get_cur_linedef(int x, int y)
 {
-  static Close_obj object;
-  const int screenslack = 15;			// Slack in pixels
-  double mapslack = fabs (screenslack / Scale);	// Slack in map units
-  int xmin = (int) (x - mapslack + 0.5);
-  int xmax = (int) (x + mapslack + 0.5);
-  int ymin = (int) (y - mapslack + 0.5);
-  int ymax = (int) (y + mapslack + 0.5);
-  object.nil ();
-  for (int n = 0; n < NumLineDefs; n++)
-  {
-    int x0 = Vertices[LineDefs[n].start].x;
-    int y0 = Vertices[LineDefs[n].start].y;
-    int x1 = Vertices[LineDefs[n].end].x;
-    int y1 = Vertices[LineDefs[n].end].y;
-    int dx;
-    int dy;
+    static Close_obj object;
+    const int screenslack = 15;	// Slack in pixels
+    double mapslack = fabs(screenslack / Scale);	// Slack in map units
+    int xmin = (int) (x - mapslack + 0.5);
+    int xmax = (int) (x + mapslack + 0.5);
+    int ymin = (int) (y - mapslack + 0.5);
+    int ymax = (int) (y + mapslack + 0.5);
+    object.nil();
+    for (int n = 0; n < NumLineDefs; n++)
+    {
+	int x0 = Vertices[LineDefs[n].start].x;
+	int y0 = Vertices[LineDefs[n].start].y;
+	int x1 = Vertices[LineDefs[n].end].x;
+	int y1 = Vertices[LineDefs[n].end].y;
+	int dx;
+	int dy;
 
-    /* Skip all lines of which all points are more than <mapslack>
-       units away from (x,y). In a typical level, this test will
-       filter out all the linedefs but a handful. */
-    if (x0 < xmin && x1 < xmin
-     || x0 > xmax && x1 > xmax
-     || y0 < ymin && y1 < ymin
-     || y0 > ymax && y1 > ymax)
-      continue;
+	/* Skip all lines of which all points are more than <mapslack>
+	   units away from (x,y). In a typical level, this test will
+	   filter out all the linedefs but a handful. */
+	if (x0 < xmin && x1 < xmin
+	    || x0 > xmax && x1 > xmax
+	    || y0 < ymin && y1 < ymin || y0 > ymax && y1 > ymax)
+	    continue;
 
-    /* This is where it gets ugly. We're trying to calculate the
-       distance between the pointer (x,y) and the linedef. Doing that
-       rigorously involves doing an orthogonal projection. I use
-       something simpler (for me).
+	/* This is where it gets ugly. We're trying to calculate the
+	   distance between the pointer (x,y) and the linedef. Doing that
+	   rigorously involves doing an orthogonal projection. I use
+	   something simpler (for me).
 
-       If the pointer is not within the ends of the linedef, I calculate
-       the distance between the pointer and the closest end.
+	   If the pointer is not within the ends of the linedef, I calculate
+	   the distance between the pointer and the closest end.
 
-       If the pointer is within the ends of the linedef, I calculate
-       what the ordinate would be for a point of the linedef that had
-       the same abscissa as the pointer. Then I calculate the difference
-       between that and the actual ordinate of the pointer and I call
-       that the distance. It's a gross approximation but, in practice,
-       it gives quite satisfactory results. Of course, for lines where
-       dy > dx, the abscissa is y and the ordinate is x.
-       -- AYM 1998-06-29 */
-    dx = x1 - x0;
-    dy = y1 - y0;
-    double dist = ULONG_MAX;
-    // The linedef is rather horizontal
-    if (abs (dx) > abs (dy))
-    {
-      /* Are we to the left of the leftmost end or to the right of the
-	 rightmost end or between the two ? */
-      if (x < (dx > 0 ? x0 : x1))
-	dist = hypot (x - (dx > 0 ? x0 : x1),
-		      y - (dx > 0 ? y0 : y1));
-      else if (x > (dx > 0 ? x1 : x0))
-	dist = hypot (x - (dx > 0 ? x1 : x0),
-		      y - (dx > 0 ? y1 : y0));
-      else
-	dist = fabs (y0 + ((double) dy)/dx * (x - x0) - y);
+	   If the pointer is within the ends of the linedef, I calculate
+	   what the ordinate would be for a point of the linedef that had
+	   the same abscissa as the pointer. Then I calculate the difference
+	   between that and the actual ordinate of the pointer and I call
+	   that the distance. It's a gross approximation but, in practice,
+	   it gives quite satisfactory results. Of course, for lines where
+	   dy > dx, the abscissa is y and the ordinate is x.
+	   -- AYM 1998-06-29 */
+	dx = x1 - x0;
+	dy = y1 - y0;
+	double dist = ULONG_MAX;
+	// The linedef is rather horizontal
+	if (abs(dx) > abs(dy))
+	{
+	    /* Are we to the left of the leftmost end or to the right of the
+	       rightmost end or between the two ? */
+	    if (x < (dx > 0 ? x0 : x1))
+		dist = hypot(x - (dx > 0 ? x0 : x1), y - (dx > 0 ? y0 : y1));
+	    else if (x > (dx > 0 ? x1 : x0))
+		dist = hypot(x - (dx > 0 ? x1 : x0), y - (dx > 0 ? y1 : y0));
+	    else
+		dist = fabs(y0 + ((double) dy) / dx * (x - x0) - y);
+	}
+	// The linedef is rather vertical
+	else
+	{
+	    /* Are we above the high end or below the low end or in between ? */
+	    if (y < (dy > 0 ? y0 : y1))
+		dist = hypot(x - (dy > 0 ? x0 : x1), y - (dy > 0 ? y0 : y1));
+	    else if (y > (dy > 0 ? y1 : y0))
+		dist = hypot(x - (dy > 0 ? x1 : x0), y - (dy > 0 ? y1 : y0));
+	    else
+		dist = fabs(x0 + ((double) dx) / dy * (y - y0) - x);
+	}
+	if (dist <= object.distance	/* "<=" because if there are superimposed
+					   linedefs, we want to return the
+					   highest-numbered one. */
+	    && dist <= mapslack)
+	{
+	    object.obj.type = OBJ_LINEDEFS;
+	    object.obj.num = n;
+	    object.distance = dist;
+	    object.radius = (int) (hypot(dx, dy) / 2);
+	    object.inside = dist < 2 * Scale;
+	}
     }
-    // The linedef is rather vertical
-    else
-    {
-      /* Are we above the high end or below the low end or in between ? */
-      if (y < (dy > 0 ? y0 : y1))
-	dist = hypot (x - (dy > 0 ? x0 : x1),
-		      y - (dy > 0 ? y0 : y1));
-      else if (y > (dy > 0 ? y1 : y0))
-	dist = hypot (x - (dy > 0 ? x1 : x0),
-		      y - (dy > 0 ? y1 : y0));
-      else
-	dist = fabs (x0 + ((double) dx)/dy * (y - y0) - x);
-    }
-    if (dist <= object.distance  /* "<=" because if there are superimposed
-				    linedefs, we want to return the
-				    highest-numbered one. */
-       && dist <= mapslack)
-    {
-      object.obj.type = OBJ_LINEDEFS;
-      object.obj.num  = n;
-      object.distance = dist;
-      object.radius   = (int) (hypot (dx, dy) / 2);
-      object.inside   = dist < 2 * Scale;
-    }
-  }
-  return object;
+    return object;
 }
 
 
 /*
  *	get_cur_sector - determine which sector is under the pointer
  */
-static const Close_obj& get_cur_sector (int x, int y)
+static const Close_obj & get_cur_sector(int x, int y)
 {
-  /* hack, hack...  I look for the first LineDef crossing
-     an horizontal half-line drawn from the cursor */
+    /* hack, hack...  I look for the first LineDef crossing
+       an horizontal half-line drawn from the cursor */
 
-  /* RQ & BW have been very smart here. Their method works remarkably
-     well for normal sectors. However, self-referencing sectors are
-     frequently unclosed. If your SRS has only horizontal linedefs, this
-     method fails miserably. I suppose that the solution would be to look
-     for intersections in BOTH directions and pick the closest. Remind me
-     to look into it one of these days :-). -- AYM 1998-06-29 */
+    /* RQ & BW have been very smart here. Their method works remarkably
+       well for normal sectors. However, self-referencing sectors are
+       frequently unclosed. If your SRS has only horizontal linedefs, this
+       method fails miserably. I suppose that the solution would be to look
+       for intersections in BOTH directions and pick the closest. Remind me
+       to look into it one of these days :-). -- AYM 1998-06-29 */
 
-  /* Initializing curx to 32767 instead of MapMaxX + 1. Fixes the old
-     DEU bug where sometimes you couldn't select a newly created sector
-     to the west of the level until you saved. (MapMaxX got out of date
-     and SaveLevelData() refreshed it.) -- AYM 1999-03-18 */
-  static Close_obj object;
-  int best_match = -1;
-  int curx = 32767;  // Oh yes, one more hard-coded constant!
-  for (int n = 0; n < NumLineDefs; n++)
-    if ((Vertices[LineDefs[n].start].y > y)
-     != (Vertices[LineDefs[n].end].y > y))
-    {
-      int lx0 = Vertices[LineDefs[n].start].x;
-      int ly0 = Vertices[LineDefs[n].start].y;
-      int lx1 = Vertices[LineDefs[n].end].x;
-      int ly1 = Vertices[LineDefs[n].end].y;
-      int m = lx0 + (int) ((long) (y - ly0) * (long) (lx1 - lx0)
-					    / (long) (ly1 - ly0));
-      if (m >= x && m < curx)
-      {
-	curx = m;
-	best_match = n;
-      }
-    }
+    /* Initializing curx to 32767 instead of MapMaxX + 1. Fixes the old
+       DEU bug where sometimes you couldn't select a newly created sector
+       to the west of the level until you saved. (MapMaxX got out of date
+       and SaveLevelData() refreshed it.) -- AYM 1999-03-18 */
+    static Close_obj object;
+    int best_match = -1;
+    int curx = 32767;		// Oh yes, one more hard-coded constant!
+    for (int n = 0; n < NumLineDefs; n++)
+	if ((Vertices[LineDefs[n].start].y > y)
+	    != (Vertices[LineDefs[n].end].y > y))
+	{
+	    int lx0 = Vertices[LineDefs[n].start].x;
+	    int ly0 = Vertices[LineDefs[n].start].y;
+	    int lx1 = Vertices[LineDefs[n].end].x;
+	    int ly1 = Vertices[LineDefs[n].end].y;
+	    int m = lx0 + (int) ((long) (y - ly0) * (long) (lx1 - lx0)
+				 / (long) (ly1 - ly0));
+	    if (m >= x && m < curx)
+	    {
+		curx = m;
+		best_match = n;
+	    }
+	}
 
-  // Now look if this linedef has a sidedef bound to one sector
-  object.nil ();
-  if (best_match >= 0)
-  {
-    if (Vertices[LineDefs[best_match].start].y
-      > Vertices[LineDefs[best_match].end].y)
-      best_match = LineDefs[best_match].sidedef1;
-    else
-      best_match = LineDefs[best_match].sidedef2;
+    // Now look if this linedef has a sidedef bound to one sector
+    object.nil();
     if (best_match >= 0)
     {
-      object.obj.type = OBJ_SECTORS;
-      object.obj.num  = SideDefs[best_match].sector;
-      object.distance = 0;	// Not meaningful for sectors
-      object.radius   = 1;	// Not meaningful for sectors
-      object.inside   = true;	// Not meaningful for sectors
+	if (Vertices[LineDefs[best_match].start].y
+	    > Vertices[LineDefs[best_match].end].y)
+	    best_match = LineDefs[best_match].sidedef1;
+	else
+	    best_match = LineDefs[best_match].sidedef2;
+	if (best_match >= 0)
+	{
+	    object.obj.type = OBJ_SECTORS;
+	    object.obj.num = SideDefs[best_match].sector;
+	    object.distance = 0;	// Not meaningful for sectors
+	    object.radius = 1;	// Not meaningful for sectors
+	    object.inside = true;	// Not meaningful for sectors
+	}
+	else;
     }
-    else
-      ;
-  }
-  else
-    ;
-  return object;
+    else;
+    return object;
 }
 
 
 /*
  *	get_cur_thing - determine which thing is under the pointer
  */
-static const Close_obj& get_cur_thing (int x, int y)
+static const Close_obj & get_cur_thing(int x, int y)
 {
-  static Close_obj closest;
-  const int screenslack = 15;			// Slack in pixels
-  double mapslack = fabs (screenslack / Scale);	// Slack in map units
-  int max_radius = (int) (get_max_thing_radius () + mapslack);
-  int xmin = x - max_radius;
-  int xmax = x + max_radius;
-  int ymin = y - max_radius;
-  int ymax = y + max_radius;
+    static Close_obj closest;
+    const int screenslack = 15;	// Slack in pixels
+    double mapslack = fabs(screenslack / Scale);	// Slack in map units
+    int max_radius = (int) (get_max_thing_radius() + mapslack);
+    int xmin = x - max_radius;
+    int xmax = x + max_radius;
+    int ymin = y - max_radius;
+    int ymax = y + max_radius;
 
-  closest.nil ();
-  for (int n = 0; n < NumThings; n++)
-  {
-    // Filter out things that are farther than <max_radius> units away.
-    if (Things[n].xpos < xmin
-     || Things[n].xpos > xmax
-     || Things[n].ypos < ymin
-     || Things[n].ypos > ymax)
-       continue;
-
-    // So how far is that thing exactly ?
-#ifdef ROUND_THINGS
-    double dist = hypot (x - Things[n].xpos, y - Things[n].ypos);
-    if (dist < closest.distance
-     && dist <= get_thing_radius (Things[n].type) + mapslack)
+    closest.nil();
+    for (int n = 0; n < NumThings; n++)
     {
-      closest.obj.type = OBJ_THINGS;
-      closest.obj.num  = n;
-      closest.distance = dist;
-      closest.radius   = get_thing_radius (Things[n].type);
-      closest.inside   = dist < closest.radius;
-    }
+	// Filter out things that are farther than <max_radius> units away.
+	if (Things[n].xpos < xmin
+	    || Things[n].xpos > xmax
+	    || Things[n].ypos < ymin || Things[n].ypos > ymax)
+	    continue;
+
+	// So how far is that thing exactly ?
+#ifdef ROUND_THINGS
+	double dist = hypot(x - Things[n].xpos, y - Things[n].ypos);
+	if (dist < closest.distance
+	    && dist <= get_thing_radius(Things[n].type) + mapslack)
+	{
+	    closest.obj.type = OBJ_THINGS;
+	    closest.obj.num = n;
+	    closest.distance = dist;
+	    closest.radius = get_thing_radius(Things[n].type);
+	    closest.inside = dist < closest.radius;
+	}
 #else
-    {
-      int thing_radius = (int) (get_thing_radius (Things[n].type) + mapslack);
-      if (x > Things[n].xpos - thing_radius
-       && x < Things[n].xpos + thing_radius
-       && y > Things[n].ypos - thing_radius
-       && y < Things[n].ypos + thing_radius)
-      {
-	Close_obj current;
-	current.obj.type = OBJ_THINGS;
-	current.obj.num  = n;
-	current.distance = hypot (x - Things[n].xpos, y - Things[n].ypos);
-	current.radius   = get_thing_radius (Things[n].type);
-	current.inside   = x > Things[n].xpos - current.radius
-			&& x < Things[n].xpos + current.radius
-			&& y > Things[n].ypos - current.radius
-			&& y < Things[n].ypos + current.radius;
-       if (current <= closest)  /* "<=" because if there are superimposed
-				   things, we want to return the
-				   highest-numbered one. */
-	  closest = current;
-      }
+	{
+	    int thing_radius =
+		(int) (get_thing_radius(Things[n].type) + mapslack);
+	    if (x > Things[n].xpos - thing_radius
+		&& x < Things[n].xpos + thing_radius
+		&& y > Things[n].ypos - thing_radius
+		&& y < Things[n].ypos + thing_radius)
+	    {
+		Close_obj current;
+		current.obj.type = OBJ_THINGS;
+		current.obj.num = n;
+		current.distance =
+		    hypot(x - Things[n].xpos, y - Things[n].ypos);
+		current.radius = get_thing_radius(Things[n].type);
+		current.inside = x > Things[n].xpos - current.radius
+		    && x < Things[n].xpos + current.radius
+		    && y > Things[n].ypos - current.radius
+		    && y < Things[n].ypos + current.radius;
+		if (current <= closest)	/* "<=" because if there are superimposed
+					   things, we want to return the
+					   highest-numbered one. */
+		    closest = current;
+	    }
+	}
+#endif
     }
-#endif
-  }
-  return closest;
+    return closest;
 }
 
 
 /*
  *	get_cur_vertex - determine which vertex is under the pointer
  */
-static const Close_obj& get_cur_vertex (int x, int y)
+static const Close_obj & get_cur_vertex(int x, int y)
 {
-  static Close_obj object;
-  const int screenradius = vertex_radius (Scale);	// Radius in pixels
-  const int screenslack  = screenradius + 15;		// Slack in pixels
-  double    mapslack     = fabs (screenslack / Scale);	// Slack in map units
-  const int mapradius    = (int) (screenradius / Scale);// Radius in map units
-  int xmin = (int) (x - mapslack + 0.5);
-  int xmax = (int) (x + mapslack + 0.5);
-  int ymin = (int) (y - mapslack + 0.5);
-  int ymax = (int) (y + mapslack + 0.5);
+    static Close_obj object;
+    const int screenradius = vertex_radius(Scale);	// Radius in pixels
+    const int screenslack = screenradius + 15;	// Slack in pixels
+    double mapslack = fabs(screenslack / Scale);	// Slack in map units
+    const int mapradius = (int) (screenradius / Scale);	// Radius in map units
+    int xmin = (int) (x - mapslack + 0.5);
+    int xmax = (int) (x + mapslack + 0.5);
+    int ymin = (int) (y - mapslack + 0.5);
+    int ymax = (int) (y + mapslack + 0.5);
 
-  object.nil ();
-  for (int n = 0; n < NumVertices; n++)
-  {
-    /* Filter out objects that are farther than <radius> units away. */
-    if (Vertices[n].x < xmin
-     || Vertices[n].x > xmax
-     || Vertices[n].y < ymin
-     || Vertices[n].y > ymax)
-       continue;
-    double dist = hypot (x - Vertices[n].x, y - Vertices[n].y);
-    if (dist <= object.distance  /* "<=" because if there are superimposed
-				   vertices, we want to return the
-				   highest-numbered one. */
-       && dist <= mapslack)
+    object.nil();
+    for (int n = 0; n < NumVertices; n++)
     {
-      object.obj.type = OBJ_VERTICES;
-      object.obj.num  = n;
-      object.distance = dist;
-      object.radius   = mapradius;
-      object.inside   = x > Vertices[n].x - mapradius
-		     && x < Vertices[n].x + mapradius
-		     && y > Vertices[n].y - mapradius
-		     && y < Vertices[n].y + mapradius;
+	/* Filter out objects that are farther than <radius> units away. */
+	if (Vertices[n].x < xmin
+	    || Vertices[n].x > xmax
+	    || Vertices[n].y < ymin || Vertices[n].y > ymax)
+	    continue;
+	double dist = hypot(x - Vertices[n].x, y - Vertices[n].y);
+	if (dist <= object.distance	/* "<=" because if there are superimposed
+					   vertices, we want to return the
+					   highest-numbered one. */
+	    && dist <= mapslack)
+	{
+	    object.obj.type = OBJ_VERTICES;
+	    object.obj.num = n;
+	    object.distance = dist;
+	    object.radius = mapradius;
+	    object.inside = x > Vertices[n].x - mapradius
+		&& x < Vertices[n].x + mapradius
+		&& y > Vertices[n].y - mapradius
+		&& y < Vertices[n].y + mapradius;
+	}
     }
-  }
-  return object;
+    return object;
 }
-
--- a/src/x_hover.h	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/x_hover.h	Sat Sep 24 14:16:04 2011 +0300
@@ -4,14 +4,14 @@
  */
 
 
-#ifndef YH_X_HOVER  /* DO NOT INSERT ANYTHING BEFORE THIS LINE */
+#ifndef YH_X_HOVER		/* DO NOT INSERT ANYTHING BEFORE THIS LINE */
 #define YH_X_HOVER
 
 
 class Objid;
 
 
-void GetCurObject (Objid& o, int objtype, int x, int y);
+void GetCurObject(Objid & o, int objtype, int x, int y);
 
 
-#endif  /* DO NOT ADD ANYTHING AFTER THIS LINE */
+#endif /* DO NOT ADD ANYTHING AFTER THIS LINE */
--- a/src/x_mirror.cc	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/x_mirror.cc	Sat Sep 24 14:16:04 2011 +0300
@@ -51,127 +51,126 @@
  *	environment (E.G. when mirroring or flipping the level
  *	too).
  */
-void flip_mirror (SelPtr list, int obj_type, char op)
+void flip_mirror(SelPtr list, int obj_type, char op)
 {
-  enum { flip, mirror } operation;
-  
-  if (op == 'f')
-    operation = flip;
-  else if (op == 'm')
-    operation = mirror;
-  else
-  {
-    nf_bug ("flip_mirror: Bad operation %02Xh", op);
-    return;
-  }
+    enum
+    { flip, mirror } operation;
+
+    if (op == 'f')
+	operation = flip;
+    else if (op == 'm')
+	operation = mirror;
+    else
+    {
+	nf_bug("flip_mirror: Bad operation %02Xh", op);
+	return;
+    }
+
+    if (!list)
+	return;
 
-  if (! list)
-    return;
+    /* Vertices, linedefs and sectors:
+       flip/mirror the vertices. */
+    if (obj_type == OBJ_VERTICES
+	|| obj_type == OBJ_LINEDEFS || obj_type == OBJ_SECTORS)
+    {
+	// Get the list of vertices to flip/mirror.
+	bitvec_c *vert;
+	if (obj_type == OBJ_LINEDEFS)
+	    vert = bv_vertices_of_linedefs(list);
+	else if (obj_type == OBJ_SECTORS)
+	    vert = bv_vertices_of_sectors(list);
+	else
+	    vert = list_to_bitvec(list, NumVertices);
 
-  /* Vertices, linedefs and sectors:
-     flip/mirror the vertices. */
-  if (obj_type == OBJ_VERTICES 
-      || obj_type == OBJ_LINEDEFS
-      || obj_type == OBJ_SECTORS)
-  {
-    // Get the list of vertices to flip/mirror.
-    bitvec_c *vert;
-    if (obj_type == OBJ_LINEDEFS)
-      vert = bv_vertices_of_linedefs (list);
-    else if (obj_type == OBJ_SECTORS)
-      vert = bv_vertices_of_sectors (list);
-    else
-      vert = list_to_bitvec (list, NumVertices);
+	/* Determine the geometric centre
+	   of that set of vertices. */
+	int xref, yref;
+	centre_of_vertices(*vert, xref, yref);
+	xref *= 2;
+	yref *= 2;
+
+	/* Change the coordinates of the
+	   vertices. */
+	if (operation == flip)
+	{
+	    int n;
+	    VPtr v;
+	    for (n = 0, v = Vertices; n < NumVertices; n++, v++)
+		if (vert->get(n))
+		    v->y = yref - v->y;
+	}
+	else if (operation == mirror)
+	{
+	    int n;
+	    VPtr v;
+	    for (n = 0, v = Vertices; n < NumVertices; n++, v++)
+		if (vert->get(n))
+		    v->x = xref - v->x;
+	}
 
-    /* Determine the geometric centre
-       of that set of vertices. */
-    int xref, yref;
-    centre_of_vertices (*vert, xref, yref);
-    xref *= 2;
-    yref *= 2;
-    
-    /* Change the coordinates of the
-       vertices. */
-    if (operation == flip)
-    {
-      int n;
-      VPtr v;
-      for (n = 0, v = Vertices; n < NumVertices; n++, v++)
-	if (vert->get (n))
-	  v->y = yref - v->y;
+	/* Flip all the linedefs between the
+	   flipped/mirrored vertices by swapping
+	   their start and end vertices. */
+	{
+	    int n;
+	    LDPtr l;
+	    for (n = 0, l = LineDefs; n < NumLineDefs; n++, l++)
+		if (vert->get(l->start) && vert->get(l->end))
+		{
+		    int w = l->start;
+		    l->start = l->end;
+		    l->end = w;
+		    MadeMapChanges = 1;
+		}
+	}
+
+	delete vert;
     }
-    else if (operation == mirror)
+
+    /* Things: flip/mirror the things. */
+    else if (obj_type == OBJ_THINGS)
     {
-      int n;
-      VPtr v;
-      for (n = 0, v = Vertices; n < NumVertices; n++, v++)
-	if (vert->get (n))
-	  v->x = xref - v->x;
-    }
-      
-    /* Flip all the linedefs between the
-       flipped/mirrored vertices by swapping
-       their start and end vertices. */
-    {
-      int n;
-      LDPtr l;
-      for (n = 0, l = LineDefs; n < NumLineDefs; n++, l++)
-	if (vert->get (l->start) && vert->get (l->end))
+	/* Determine the geometric centre
+	   of that set of things. */
+	int xref, yref;
+	centre_of_things(list, &xref, &yref);
+	xref *= 2;
+	yref *= 2;
+
+	/* Change the coordinates of the
+	   things and adjust the angles. */
+	if (operation == flip)
 	{
-	  int w = l->start;
-	  l->start = l->end;
-	  l->end = w;
-	  MadeMapChanges = 1;
+	    if (list)
+	    {
+		things_angles++;
+		MadeChanges = 1;
+	    }
+	    for (SelPtr cur = list; cur; cur = cur->next)
+	    {
+		TPtr t = Things + cur->objnum;
+		t->ypos = yref - t->ypos;
+		if (t->angle != 0)
+		    t->angle = 360 - t->angle;
+	    }
+	}
+	else if (operation == mirror)
+	{
+	    if (list)
+	    {
+		things_angles++;
+		MadeChanges = 1;
+	    }
+	    for (SelPtr cur = list; cur; cur = cur->next)
+	    {
+		TPtr t = Things + cur->objnum;
+		t->xpos = xref - t->xpos;
+		if (t->angle > 180)
+		    t->angle = 540 - t->angle;
+		else
+		    t->angle = 180 - t->angle;
+	    }
 	}
     }
-    
-    delete vert;
-  }
-
-  /* Things: flip/mirror the things. */
-  else if (obj_type == OBJ_THINGS)
-  {
-    /* Determine the geometric centre
-       of that set of things. */
-    int xref, yref;
-    centre_of_things (list, &xref, &yref);
-    xref *= 2;
-    yref *= 2;
-
-    /* Change the coordinates of the
-       things and adjust the angles. */
-    if (operation == flip)
-    {
-      if (list)
-      {
-	things_angles++;
-	MadeChanges = 1;
-      }
-      for (SelPtr cur = list; cur; cur = cur->next)
-      {
-	TPtr t = Things + cur->objnum;
-	t->ypos = yref - t->ypos;
-	if (t->angle != 0)
-	  t->angle = 360 - t->angle;
-      }
-    }
-    else if (operation == mirror)
-    {
-      if (list)
-      {
-	things_angles++;
-	MadeChanges = 1;
-      }
-      for (SelPtr cur = list; cur; cur = cur->next)
-      {
-	TPtr t = Things + cur->objnum;
-	t->xpos = xref - t->xpos;
-	if (t->angle > 180)
-	  t->angle = 540 - t->angle;
-	else
-	  t->angle = 180 - t->angle;
-      }
-    }
-  }
 }
-
--- a/src/x_mirror.h	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/x_mirror.h	Sat Sep 24 14:16:04 2011 +0300
@@ -5,6 +5,4 @@
  */
 
 
-void flip_mirror (SelPtr list, int obj_type, char op);
-
-
+void flip_mirror(SelPtr list, int obj_type, char op);
--- a/src/x_rotate.cc	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/x_rotate.cc	Sat Sep 24 14:16:04 2011 +0300
@@ -45,14 +45,14 @@
 */
 
 #if 0
-inline void RotateAndScaleCoords (int *x, int *y, double angle, double scale)
+inline void RotateAndScaleCoords(int *x, int *y, double angle, double scale)
 {
-  double r, theta;
+    double r, theta;
 
-  r = hypot ((double) *x, (double) *y);
-  theta = atan2 ((double) *y, (double) *x);
-  *x = (int) (r * scale * cos (theta + angle) + 0.5);
-  *y = (int) (r * scale * sin (theta + angle) + 0.5);
+    r = hypot((double) *x, (double) *y);
+    theta = atan2((double) *y, (double) *x);
+    *x = (int) (r * scale * cos(theta + angle) + 0.5);
+    *y = (int) (r * scale * sin(theta + angle) + 0.5);
 }
 #endif
 
@@ -61,57 +61,54 @@
    rotate and scale a group of objects around the centre of gravity
 */
 
-void RotateAndScaleObjects (int objtype, SelPtr obj, double angle, double scale) /* SWAP! */
+void RotateAndScaleObjects(int objtype, SelPtr obj, double angle, double scale)	/* SWAP! */
 {
-  int    dx, dy;
-  int    centerx, centery;
-  SelPtr cur, vertices;
+    int dx, dy;
+    int centerx, centery;
+    SelPtr cur, vertices;
 
-  if (obj == NULL)
-    return;
+    if (obj == NULL)
+	return;
 
-  switch (objtype)
-  {
+    switch (objtype)
+    {
     case OBJ_THINGS:
-      centre_of_things (obj, &centerx, &centery);
-      for (cur = obj; cur; cur = cur->next)
-	 {
-	 dx = Things[cur->objnum].xpos - centerx;
-	 dy = Things[cur->objnum].ypos - centery;
-	 RotateAndScaleCoords (&dx, &dy, angle, scale);
-	 Things[cur->objnum].xpos = centerx + dx;
-	 Things[cur->objnum].ypos = centery + dy;
-	 }
-      MadeChanges = 1;
-      break;
+	centre_of_things(obj, &centerx, &centery);
+	for (cur = obj; cur; cur = cur->next)
+	{
+	    dx = Things[cur->objnum].xpos - centerx;
+	    dy = Things[cur->objnum].ypos - centery;
+	    RotateAndScaleCoords(&dx, &dy, angle, scale);
+	    Things[cur->objnum].xpos = centerx + dx;
+	    Things[cur->objnum].ypos = centery + dy;
+	}
+	MadeChanges = 1;
+	break;
 
     case OBJ_VERTICES:
-      centre_of_vertices (obj, &centerx, &centery);
-      for (cur = obj; cur; cur = cur->next)
-	 {
-	 dx = Vertices[cur->objnum].x - centerx;
-	 dy = Vertices[cur->objnum].y - centery;
-	 RotateAndScaleCoords (&dx, &dy, angle, scale);
-	 Vertices[cur->objnum].x = (centerx + dx + /*4*/ 2) & ~/*7*/3;
-	 Vertices[cur->objnum].y = (centery + dy + /*4*/ 2) & ~/*7*/3;
-	 }
-      MadeChanges = 1;
-      MadeMapChanges = 1;
-      break;
+	centre_of_vertices(obj, &centerx, &centery);
+	for (cur = obj; cur; cur = cur->next)
+	{
+	    dx = Vertices[cur->objnum].x - centerx;
+	    dy = Vertices[cur->objnum].y - centery;
+	    RotateAndScaleCoords(&dx, &dy, angle, scale);
+	    Vertices[cur->objnum].x = (centerx + dx + /*4 */ 2) & ~ /*7 */ 3;
+	    Vertices[cur->objnum].y = (centery + dy + /*4 */ 2) & ~ /*7 */ 3;
+	}
+	MadeChanges = 1;
+	MadeMapChanges = 1;
+	break;
 
     case OBJ_LINEDEFS:
-      vertices = list_vertices_of_linedefs (obj);
-      RotateAndScaleObjects (OBJ_VERTICES, vertices, angle, scale);
-      ForgetSelection (&vertices);
-      break;
+	vertices = list_vertices_of_linedefs(obj);
+	RotateAndScaleObjects(OBJ_VERTICES, vertices, angle, scale);
+	ForgetSelection(&vertices);
+	break;
 
     case OBJ_SECTORS:
-      vertices = list_vertices_of_sectors (obj);
-      RotateAndScaleObjects (OBJ_VERTICES, vertices, angle, scale);
-      ForgetSelection (&vertices);
-      break;
-  }
+	vertices = list_vertices_of_sectors(obj);
+	RotateAndScaleObjects(OBJ_VERTICES, vertices, angle, scale);
+	ForgetSelection(&vertices);
+	break;
+    }
 }
-
-
-
--- a/src/x_rotate.h	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/x_rotate.h	Sat Sep 24 14:16:04 2011 +0300
@@ -30,15 +30,14 @@
 #include <math.h>
 
 
-inline void RotateAndScaleCoords (int *x, int *y, double angle, double scale)
+inline void RotateAndScaleCoords(int *x, int *y, double angle, double scale)
 {
-  double r, theta;
+    double r, theta;
 
-  r = hypot ((double) *x, (double) *y);
-  theta = atan2 ((double) *y, (double) *x);
-  *x = (int) (r * scale * cos (theta + angle) + 0.5);
-  *y = (int) (r * scale * sin (theta + angle) + 0.5);
+    r = hypot((double) *x, (double) *y);
+    theta = atan2((double) *y, (double) *x);
+    *x = (int) (r * scale * cos(theta + angle) + 0.5);
+    *y = (int) (r * scale * sin(theta + angle) + 0.5);
 }
 
-void RotateAndScaleObjects (int, SelPtr, double, double);
-
+void RotateAndScaleObjects(int, SelPtr, double, double);
--- a/src/xref.cc	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/xref.cc	Sat Sep 24 14:16:04 2011 +0300
@@ -34,100 +34,99 @@
 #include "selectn.h"
 
 
-void xref_sidedef ()
+void xref_sidedef()
 {
-  int sidedef_no;
-  printf ("Enter sidedef number : ");
-  scanf ("%d", &sidedef_no);
-  printf ("Sidedef %d is used by linedefs:", sidedef_no);
-  int count = 0;
-  for (int n = 0; n < NumLineDefs; n++)
-  {
-    if (LineDefs[n].sidedef1 == sidedef_no)
+    int sidedef_no;
+    printf("Enter sidedef number : ");
+    scanf("%d", &sidedef_no);
+    printf("Sidedef %d is used by linedefs:", sidedef_no);
+    int count = 0;
+    for (int n = 0; n < NumLineDefs; n++)
     {
-      printf (" %dR", n);
-      count++;
+	if (LineDefs[n].sidedef1 == sidedef_no)
+	{
+	    printf(" %dR", n);
+	    count++;
+	}
+	if (LineDefs[n].sidedef2 == sidedef_no)
+	{
+	    printf(" %dL", n);
+	    count++;
+	}
     }
-    if (LineDefs[n].sidedef2 == sidedef_no)
-    {
-      printf (" %dL", n);
-      count++;
-    }
-  }
-  printf (" (total %d linedefs)\n", count);
+    printf(" (total %d linedefs)\n", count);
 }
 
 
-void secret_sectors ()
+void secret_sectors()
 {
-  printf ("Secret sectors:");
-  int count = 0;
-  for (int n = 0; n < NumSectors; n++)
-    if (Sectors[n].special ==  9)  // FIXME hard-coded
-    {
-      printf (" %d", n);
-      count++;
-    }
-  printf (" (total %d)\n", count);
+    printf("Secret sectors:");
+    int count = 0;
+    for (int n = 0; n < NumSectors; n++)
+	if (Sectors[n].special == 9)	// FIXME hard-coded
+	{
+	    printf(" %d", n);
+	    count++;
+	}
+    printf(" (total %d)\n", count);
 
 }
 
 
-void unknown_linedef_type (SelPtr *list)
+void unknown_linedef_type(SelPtr * list)
 {
-  for (int n = 0; n < NumLineDefs; n++)
-    if (*GetLineDefTypeName (LineDefs[n].type) == '?')
-      SelectObject (list, n);
+    for (int n = 0; n < NumLineDefs; n++)
+	if (*GetLineDefTypeName(LineDefs[n].type) == '?')
+	    SelectObject(list, n);
 }
 
 
-void bad_sector_number (SelPtr *list)
+void bad_sector_number(SelPtr * list)
 {
-  for (int n = 0; n < NumLineDefs; n++)
-  {
-    int s1 = LineDefs[n].sidedef1;
-    int s2 = LineDefs[n].sidedef2;
-    if (s1 >= 0 && s1 < NumSideDefs
-	&& SideDefs[s1].sector < 0 || SideDefs[s1].sector >= NumSectors
-     || s2 >= 0 && s2 < NumSideDefs
-        && SideDefs[s2].sector < 0 || SideDefs[s2].sector >= NumSectors)
-      SelectObject (list, n);
-  }
+    for (int n = 0; n < NumLineDefs; n++)
+    {
+	int s1 = LineDefs[n].sidedef1;
+	int s2 = LineDefs[n].sidedef2;
+	if (s1 >= 0 && s1 < NumSideDefs
+	    && SideDefs[s1].sector < 0 || SideDefs[s1].sector >= NumSectors
+	    || s2 >= 0 && s2 < NumSideDefs
+	    && SideDefs[s2].sector < 0 || SideDefs[s2].sector >= NumSectors)
+	    SelectObject(list, n);
+    }
 }
 
 
 /*
  *	A stopgap to please IvL
  */
-void list_tagged_sectors (int tag)
+void list_tagged_sectors(int tag)
 {
-  printf ("tag %d:", tag);
-  int count = 0;
+    printf("tag %d:", tag);
+    int count = 0;
 
-  for (int n = 0; n < NumSectors; n++)
-    if (Sectors[n].tag == tag)
-    {
-      printf (" %d", n);
-      count++;
-    }
-  printf (" (total %d)\n", count);
+    for (int n = 0; n < NumSectors; n++)
+	if (Sectors[n].tag == tag)
+	{
+	    printf(" %d", n);
+	    count++;
+	}
+    printf(" (total %d)\n", count);
 }
 
 
 /*
  *	A stopgap to please IvL
  */
-void list_tagged_linedefs (int tag)
+void list_tagged_linedefs(int tag)
 {
-  printf ("tag %d:", tag);
-  int count = 0;
+    printf("tag %d:", tag);
+    int count = 0;
 
-  for (int n = 0; n < NumLineDefs; n++)
-    if (LineDefs[n].tag == tag)
-    {
-      printf (" %d", n);
-      count++;
-    }
-  printf (" (total %d)\n", count);
+    for (int n = 0; n < NumLineDefs; n++)
+	if (LineDefs[n].tag == tag)
+	{
+	    printf(" %d", n);
+	    count++;
+	}
+    printf(" (total %d)\n", count);
 }
-
--- a/src/xref.h	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/xref.h	Sat Sep 24 14:16:04 2011 +0300
@@ -6,11 +6,9 @@
  */
 
 
-void xref_sidedef ();
-void secret_sectors ();
-void unknown_linedef_type (SelPtr *list);
-void bad_sector_number (SelPtr *list);
-void list_tagged_sectors (int tag);
-void list_tagged_linedefs (int tag);
-
-
+void xref_sidedef();
+void secret_sectors();
+void unknown_linedef_type(SelPtr * list);
+void bad_sector_number(SelPtr * list);
+void list_tagged_sectors(int tag);
+void list_tagged_linedefs(int tag);
--- a/src/yadex.cc	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/yadex.cc	Sat Sep 24 14:16:04 2011 +0300
@@ -33,18 +33,18 @@
 #include "acolours.h"
 #include "bench.h"
 #include "cfgfile.h"
-#include "disppic.h"  /* Because of "p" */
+#include "disppic.h"		/* Because of "p" */
 #include "editlev.h"
 #include "endian.h"
 #include "flats.h"
 #include "game.h"
 #include "gfx.h"
 #include "help1.h"
-#include "levels.h"    /* Because of "viewtex" */
+#include "levels.h"		/* Because of "viewtex" */
 #include "lists.h"
 #include "mkpalette.h"
 #include "palview.h"
-#include "patchdir.h"  /* Because of "p" */
+#include "patchdir.h"		/* Because of "p" */
 #include "rgb.h"
 #include "sanity.h"
 #include "textures.h"
@@ -59,130 +59,131 @@
 /*
  *	Constants (declared in yadex.h)
  */
-const char *const log_file       = "yadex.log";
+const char *const log_file = "yadex.log";
 const char *const msg_unexpected = "unexpected error";
-const char *const msg_nomem      = "Not enough memory";
+const char *const msg_nomem = "Not enough memory";
 
 
 /*
  *	Not real variables -- just unique pointer values
  *	used by functions that return pointers to 
  */
-char error_non_unique[1];  // Found more than one
-char error_none[1];        // Found none
-char error_invalid[1];     // Invalid parameter
+char error_non_unique[1];	// Found more than one
+char error_none[1];		// Found none
+char error_invalid[1];		// Invalid parameter
 
 
 /*
  *	Global variables
  */
-const char *install_dir = 0;		// Where Yadex is installed
-FILE *      logfile     = NULL;		// Filepointer to the error log
-bool        Registered  = false;	// Registered or shareware game?
-int         screen_lines = 24;  	// Lines that our TTY can display
-int         remind_to_build_nodes = 0;	// Remind user to build nodes
-Wad_res     wad_res (&MasterDir);
+const char *install_dir = 0;	// Where Yadex is installed
+FILE *logfile = NULL;		// Filepointer to the error log
+bool Registered = false;	// Registered or shareware game?
+int screen_lines = 24;		// Lines that our TTY can display
+int remind_to_build_nodes = 0;	// Remind user to build nodes
+Wad_res wad_res(&MasterDir);
 
 // Set from command line and/or config file
-bool      autoscroll			= 0;
-unsigned long autoscroll_amp		= 10;
-unsigned long autoscroll_edge		= 30;
-const char *config_file                 = NULL;
-int       copy_linedef_reuse_sidedefs	= 0;
-int       cpu_big_endian		= 0;
-bool      Debug				= false;
-int       default_ceiling_height	= 128;
-char      default_ceiling_texture[WAD_FLAT_NAME + 1]	= "CEIL3_5";
-int       default_floor_height				= 0;
-char      default_floor_texture[WAD_FLAT_NAME + 1]	= "FLOOR4_8";
-int       default_light_level				= 144;
-char      default_lower_texture[WAD_TEX_NAME + 1]	= "STARTAN3";
-char      default_middle_texture[WAD_TEX_NAME + 1]	= "STARTAN3";
-char      default_upper_texture[WAD_TEX_NAME + 1]	= "STARTAN3";
-int       default_thing			= 3004;
-int       double_click_timeout		= 200;
-bool      Expert			= false;
-const char *Game			= NULL;
-int       grid_pixels_min		= 10;
-int       GridMin			= 2;
-int       GridMax			= 128;
-int       idle_sleep_ms			= 50;
-bool      InfoShown			= true;
-int       zoom_default			= 0;  // 0 means fit
-int       zoom_step			= 0;  // 0 means sqrt(2)
-int       digit_zoom_base               = 100;
-int       digit_zoom_step               = 0;  // 0 means sqrt(2)
-confirm_t insert_vertex_split_linedef	= YC_ASK_ONCE;
-confirm_t insert_vertex_merge_vertices	= YC_ASK_ONCE;
-bool      blindly_swap_sidedefs         = false;
-const char *Iwad1			= NULL;
-const char *Iwad2			= NULL;
-const char *Iwad3			= NULL;
-const char *Iwad4			= NULL;
-const char *Iwad5			= NULL;
-const char *Iwad6			= NULL;
-const char *Iwad7			= NULL;
-const char *Iwad8			= NULL;
-const char *Iwad9			= NULL;
-const char *Iwad10			= NULL;
-const char *MainWad			= NULL;
+bool autoscroll = 0;
+unsigned long autoscroll_amp = 10;
+unsigned long autoscroll_edge = 30;
+const char *config_file = NULL;
+int copy_linedef_reuse_sidedefs = 0;
+int cpu_big_endian = 0;
+bool Debug = false;
+int default_ceiling_height = 128;
+char default_ceiling_texture[WAD_FLAT_NAME + 1] = "CEIL3_5";
+int default_floor_height = 0;
+char default_floor_texture[WAD_FLAT_NAME + 1] = "FLOOR4_8";
+int default_light_level = 144;
+char default_lower_texture[WAD_TEX_NAME + 1] = "STARTAN3";
+char default_middle_texture[WAD_TEX_NAME + 1] = "STARTAN3";
+char default_upper_texture[WAD_TEX_NAME + 1] = "STARTAN3";
+int default_thing = 3004;
+int double_click_timeout = 200;
+bool Expert = false;
+const char *Game = NULL;
+int grid_pixels_min = 10;
+int GridMin = 2;
+int GridMax = 128;
+int idle_sleep_ms = 50;
+bool InfoShown = true;
+int zoom_default = 0;		// 0 means fit
+int zoom_step = 0;		// 0 means sqrt(2)
+int digit_zoom_base = 100;
+int digit_zoom_step = 0;	// 0 means sqrt(2)
+confirm_t insert_vertex_split_linedef = YC_ASK_ONCE;
+confirm_t insert_vertex_merge_vertices = YC_ASK_ONCE;
+bool blindly_swap_sidedefs = false;
+const char *Iwad1 = NULL;
+const char *Iwad2 = NULL;
+const char *Iwad3 = NULL;
+const char *Iwad4 = NULL;
+const char *Iwad5 = NULL;
+const char *Iwad6 = NULL;
+const char *Iwad7 = NULL;
+const char *Iwad8 = NULL;
+const char *Iwad9 = NULL;
+const char *Iwad10 = NULL;
+const char *MainWad = NULL;
 #ifdef AYM_MOUSE_HACKS
-int       MouseMickeysH			= 5;
-int       MouseMickeysV			= 5;
+int MouseMickeysH = 5;
+int MouseMickeysV = 5;
 #endif
-char **   PatchWads			= NULL;
-bool      Quiet				= false;
-bool      Quieter			= false;
-unsigned long scroll_less		= 10;
-unsigned long scroll_more		= 90;
-bool      Select0			= false;
-int       show_help			= 0;
-int       sprite_scale                  = 100;
-bool      SwapButtons			= false;
-int       verbose			= 0;
-int       welcome_message		= 1;
-const char *bench			= 0;
+char **PatchWads = NULL;
+bool Quiet = false;
+bool Quieter = false;
+unsigned long scroll_less = 10;
+unsigned long scroll_more = 90;
+bool Select0 = false;
+int show_help = 0;
+int sprite_scale = 100;
+bool SwapButtons = false;
+int verbose = 0;
+int welcome_message = 1;
+const char *bench = 0;
 
 // Global variables declared in game.h
-yglf_t yg_level_format   = YGLF__;
-ygln_t yg_level_name     = YGLN__;
+yglf_t yg_level_format = YGLF__;
+ygln_t yg_level_name = YGLN__;
 ygpf_t yg_picture_format = YGPF_NORMAL;
 ygtf_t yg_texture_format = YGTF_NORMAL;
-ygtl_t yg_texture_lumps  = YGTL_NORMAL;
-al_llist_t *ldtdef       = NULL;
-al_llist_t *ldtgroup     = NULL;
-al_llist_t *stdef        = NULL;
-al_llist_t *thingdef     = NULL;
-al_llist_t *thinggroup   = NULL;
+ygtl_t yg_texture_lumps = YGTL_NORMAL;
+al_llist_t *ldtdef = NULL;
+al_llist_t *ldtgroup = NULL;
+al_llist_t *stdef = NULL;
+al_llist_t *thingdef = NULL;
+al_llist_t *thinggroup = NULL;
 Wad_name sky_flat;
 
 
 /*
  *	Prototypes of private functions
  */
-static int  parse_environment_vars ();
-static void MainLoop ();
-static void print_error_message (const char *fmt, va_list args);
-static void add_base_colours ();
-static const Wad_file *wad_by_name (const char *pathname);
-static bool wad_already_loaded (const char *pathname);
+static int parse_environment_vars();
+static void MainLoop();
+static void print_error_message(const char *fmt, va_list args);
+static void add_base_colours();
+static const Wad_file *wad_by_name(const char *pathname);
+static bool wad_already_loaded(const char *pathname);
 
-typedef struct {
+typedef struct
+{
     const char *game, *wadname;
     const char **pwadloc;
 } GameInfo;
 
 GameInfo gameList[] = {
-    { "doom",      "doom.wad",                   &Iwad1 },
-    { "doom2",     "doom2.wad",                  &Iwad2 },
-    { "heretic",   "heretic.wad",                &Iwad3 },
-    { "hexen",     "hexen.wad",                  &Iwad4 },
-    { "strife",    "strife1.wad",                &Iwad5 },
-    { "doom02",    "Doom alpha 0.2 IWAD",        &Iwad6 },
-    { "doom04",    "Doom alpha 0.4 IWAD",        &Iwad7 },
-    { "doom05",    "Doom alpha 0.5 IWAD",        &Iwad8 },
-    { "doompr",    "Doom Press Release IWAD",    &Iwad9 },
-    { "strife10",  "strife1.wad",                &Iwad10 }
+    {"doom", "doom.wad", &Iwad1},
+    {"doom2", "doom2.wad", &Iwad2},
+    {"heretic", "heretic.wad", &Iwad3},
+    {"hexen", "hexen.wad", &Iwad4},
+    {"strife", "strife1.wad", &Iwad5},
+    {"doom02", "Doom alpha 0.2 IWAD", &Iwad6},
+    {"doom04", "Doom alpha 0.4 IWAD", &Iwad7},
+    {"doom05", "Doom alpha 0.5 IWAD", &Iwad8},
+    {"doompr", "Doom Press Release IWAD", &Iwad9},
+    {"strife10", "strife1.wad", &Iwad10}
 };
 
 const int ngameList = sizeof(gameList) / sizeof(gameList[0]);
@@ -192,184 +193,191 @@
  *	main
  *	Guess what.
  */
-int main (int argc, char *argv[])
+int main(int argc, char *argv[])
 {
-int r;
+    int r;
 
 // Set <screen_lines>
-if (getenv ("LINES") != NULL)
-   screen_lines = atoi (getenv ("LINES"));
-else
-   screen_lines = 0;
-if (screen_lines == 0)
-   screen_lines = 24;
+    if (getenv("LINES") != NULL)
+	screen_lines = atoi(getenv("LINES"));
+    else
+	screen_lines = 0;
+    if (screen_lines == 0)
+	screen_lines = 24;
 
 // First detect manually --help and --version
 // because parse_command_line_options() cannot.
-if (argc == 2 && strcmp (argv[1], "--help") == 0)
-   {
-   print_usage (stdout);
-   if (fflush (stdout) != 0)
-     fatal_error ("stdout: %s", strerror (errno));
-   exit (0);
-   }
-if (argc == 2 && strcmp (argv[1], "--version") == 0)
-   {
-   puts (what ());
-   puts (config_file_magic);
-   puts (ygd_file_magic);
-   if (fflush (stdout) != 0)
-     fatal_error ("stdout: %s", strerror (errno));
-   exit (0);
-   }
+    if (argc == 2 && strcmp(argv[1], "--help") == 0)
+    {
+	print_usage(stdout);
+	if (fflush(stdout) != 0)
+	    fatal_error("stdout: %s", strerror(errno));
+	exit(0);
+    }
+    if (argc == 2 && strcmp(argv[1], "--version") == 0)
+    {
+	puts(what());
+	puts(config_file_magic);
+	puts(ygd_file_magic);
+	if (fflush(stdout) != 0)
+	    fatal_error("stdout: %s", strerror(errno));
+	exit(0);
+    }
 
 // Second a quick pass through the command line
 // arguments to detect -?, -f and -help.
-r = parse_command_line_options (argc - 1, argv + 1, 1);
-if (r)
-   goto syntax_error;
+    r = parse_command_line_options(argc - 1, argv + 1, 1);
+    if (r)
+	goto syntax_error;
 
-if (show_help)
-   {
-   print_usage (stdout);
-   exit (1);
-   }
+    if (show_help)
+    {
+	print_usage(stdout);
+	exit(1);
+    }
 
-printf ("%s\n", what ());
+    printf("%s\n", what());
 
 // Where am I installed ? (the config file might be there)
 #if defined Y_DOS
-install_dir = spec_path (argv[0]);
+    install_dir = spec_path(argv[0]);
 #endif
 
 // The config file provides some values.
-if (config_file != NULL)
-  r = parse_config_file_user (config_file);
-else
-  r = parse_config_file_default ();
-if (r == 0)
-   {
-   // Environment variables can override them.
-   r = parse_environment_vars ();
-   if (r == 0)
-      {
-      // And the command line argument can override both.
-      r = parse_command_line_options (argc - 1, argv + 1, 2);
-      }
-   }
-if (r != 0)
-   {
-   syntax_error :
-   fprintf (stderr, "Try \"yadex --help\" or \"man yadex\".\n");
-   exit (1);
-   }
+    if (config_file != NULL)
+	r = parse_config_file_user(config_file);
+    else
+	r = parse_config_file_default();
+    if (r == 0)
+    {
+	// Environment variables can override them.
+	r = parse_environment_vars();
+	if (r == 0)
+	{
+	    // And the command line argument can override both.
+	    r = parse_command_line_options(argc - 1, argv + 1, 2);
+	}
+    }
+    if (r != 0)
+    {
+      syntax_error:
+	fprintf(stderr, "Try \"yadex --help\" or \"man yadex\".\n");
+	exit(1);
+    }
 
-if (Game != NULL) {
-   int n;
-   for (n = 0; n < ngameList; n++) {
-      GameInfo *info = &gameList[n];
-      if (strcmp(Game, info->game) == 0) {
-         if (*(info->pwadloc) == NULL) {
-            err("You have to tell me where %s is.", info->wadname);
-            fprintf(stderr,
-                "Use \"-i%d <file>\" or put \"iwad%d=<file>\" in yadex.cfg\n",
-                n+1, n+1);
-            exit(1);
-         }
-         MainWad = *(info->pwadloc);
-      }
-   }
-}
+    if (Game != NULL)
+    {
+	int n;
+	for (n = 0; n < ngameList; n++)
+	{
+	    GameInfo *info = &gameList[n];
+	    if (strcmp(Game, info->game) == 0)
+	    {
+		if (*(info->pwadloc) == NULL)
+		{
+		    err("You have to tell me where %s is.", info->wadname);
+		    fprintf(stderr,
+			    "Use \"-i%d <file>\" or put \"iwad%d=<file>\" in yadex.cfg\n",
+			    n + 1, n + 1);
+		    exit(1);
+		}
+		MainWad = *(info->pwadloc);
+	    }
+	}
+    }
 
-if (MainWad == NULL) {
-   int n;
-   if (Game == NULL)
-      err ("You didn't say for which game you want to edit.");
-   else
-      err ("Unknown game \"%s\"", Game);
-   fprintf (stderr,
-   "Use \"-g <game>\" on the command line or put \"game=<game>\" in yadex.cfg\n"
-   "where <game> is one of: ");
-   for (n = 0; n < ngameList; n++) {
-       fprintf(stderr, "%s\"%s\"", n > 0 ? ", " : "", gameList[n].game);
-   }
-   fprintf(stderr, ".\n");
-   exit (1);
-   }
-if (Debug)
-   {
-   logfile = fopen (log_file, "a");
-   if (logfile == NULL)
-      warn ("can't open log file \"%s\" (%s)", log_file, strerror (errno));
-   LogMessage (": Welcome to Yadex!\n");
-   }
-if (Quieter)
-   Quiet = true;
+    if (MainWad == NULL)
+    {
+	int n;
+	if (Game == NULL)
+	    err("You didn't say for which game you want to edit.");
+	else
+	    err("Unknown game \"%s\"", Game);
+	fprintf(stderr,
+		"Use \"-g <game>\" on the command line or put \"game=<game>\" in yadex.cfg\n"
+		"where <game> is one of: ");
+	for (n = 0; n < ngameList; n++)
+	{
+	    fprintf(stderr, "%s\"%s\"", n > 0 ? ", " : "", gameList[n].game);
+	}
+	fprintf(stderr, ".\n");
+	exit(1);
+    }
+    if (Debug)
+    {
+	logfile = fopen(log_file, "a");
+	if (logfile == NULL)
+	    warn("can't open log file \"%s\" (%s)", log_file,
+		 strerror(errno));
+	LogMessage(": Welcome to Yadex!\n");
+    }
+    if (Quieter)
+	Quiet = true;
 
 // Sanity checks (useful when porting).
-check_types ();
-check_charset ();
+    check_types();
+    check_charset();
 
 // Misc. things done only once.
-cpu_big_endian = native_endianness ();
-add_base_colours ();
+    cpu_big_endian = native_endianness();
+    add_base_colours();
 
 // Load game definitions (*.ygd).
-InitGameDefs ();
-LoadGameDefs (Game);
+    InitGameDefs();
+    LoadGameDefs(Game);
 
 // Load the iwad and the pwads.
-if (OpenMainWad (MainWad))
-   fatal_error ("If you don't give me an iwad, I'll quit. I'm serious.");
-if (PatchWads)
-   {
-   const char * const *pwad_name;
-   for (pwad_name = PatchWads; *pwad_name; pwad_name++)
-      OpenPatchWad (*pwad_name);
-   }
+    if (OpenMainWad(MainWad))
+	fatal_error("If you don't give me an iwad, I'll quit. I'm serious.");
+    if (PatchWads)
+    {
+	const char *const *pwad_name;
+	for (pwad_name = PatchWads; *pwad_name; pwad_name++)
+	    OpenPatchWad(*pwad_name);
+    }
 /* sanity check */
-CloseUnusedWadFiles ();
+    CloseUnusedWadFiles();
 
 // BRANCH 1 : benchmarking (-b)
-if (bench != 0)
-   {
-   benchmark (bench);
-   return 0;  // Exit successfully
-   }
+    if (bench != 0)
+    {
+	benchmark(bench);
+	return 0;		// Exit successfully
+    }
 
 // BRANCH 2 : normal use ("yadex:" prompt)
-else
-   {
-   if (welcome_message)
-      print_welcome (stdout);
+    else
+    {
+	if (welcome_message)
+	    print_welcome(stdout);
 
-   if (strcmp (Game, "hexen") == 0)
-      printf (
-   "WARNING: Hexen mode is experimental. Don't expect to be able to do any\n"
-   "real Hexen editing with it. You can edit levels but you can't save them.\n"
-   "And there might be other bugs... BE CAREFUL !\n\n");
+	if (strcmp(Game, "hexen") == 0)
+	    printf
+		("WARNING: Hexen mode is experimental. Don't expect to be able to do any\n"
+		 "real Hexen editing with it. You can edit levels but you can't save them.\n"
+		 "And there might be other bugs... BE CAREFUL !\n\n");
 
-   if (strcmp (Game, "strife") == 0)
-      printf (
-   "WARNING: Strife mode is experimental. Many thing types, linedef types,\n"
-   "etc. are missing or wrong. And be careful, there might be bugs.\n\n");
+	if (strcmp(Game, "strife") == 0)
+	    printf
+		("WARNING: Strife mode is experimental. Many thing types, linedef types,\n"
+		 "etc. are missing or wrong. And be careful, there might be bugs.\n\n");
 
-   /* all systems go! */
-   MainLoop ();
-   }
+	/* all systems go! */
+	MainLoop();
+    }
 
 /* that's all, folks! */
-CloseWadFiles ();
-FreeGameDefs ();
-LogMessage (": The end!\n\n\n");
-if (logfile != NULL)
-   fclose (logfile);
-if (remind_to_build_nodes)
-   printf ("\n"
-      "** You have made changes to one or more wads. Don't forget to pass\n"
-      "** them through a nodes builder (E.G. BSP) before running them.\n"
-      "** Like this: \"ybsp foo.wad -o tmp.wad; doom -file tmp.wad\"\n\n");
-return 0;
+    CloseWadFiles();
+    FreeGameDefs();
+    LogMessage(": The end!\n\n\n");
+    if (logfile != NULL)
+	fclose(logfile);
+    if (remind_to_build_nodes)
+	printf("\n"
+	       "** You have made changes to one or more wads. Don't forget to pass\n"
+	       "** them through a nodes builder (E.G. BSP) before running them.\n"
+	       "** Like this: \"ybsp foo.wad -o tmp.wad; doom -file tmp.wad\"\n\n");
+    return 0;
 }
 
 
@@ -378,14 +386,14 @@
  *	Check certain environment variables.
  *	Returns 0 on success, <>0 on error.
  */
-static int parse_environment_vars ()
+static int parse_environment_vars()
 {
-char *value;
+    char *value;
 
-value = getenv ("YADEX_GAME");
-if (value != NULL)
-   Game = value;
-return 0;
+    value = getenv("YADEX_GAME");
+    if (value != NULL)
+	Game = value;
+    return 0;
 }
 
 
@@ -393,7 +401,7 @@
    play a fascinating tune
 */
 
-void Beep ()
+void Beep()
 {
 }
 
@@ -403,18 +411,18 @@
    play a sound
 */
 
-void PlaySound (int freq, int msec)
+void PlaySound(int freq, int msec)
 {
 #if defined Y_DOS
-if (! Quiet)
-   {
-   sound (freq);
-   delay (msec);
-   nosound ();
-   }
+    if (!Quiet)
+    {
+	sound(freq);
+	delay(msec);
+	nosound();
+    }
 #elif defined Y_UNIX
-freq = msec;	// To prevent a warning about unused variables
-return;
+    freq = msec;		// To prevent a warning about unused variables
+    return;
 #endif
 }
 
@@ -424,24 +432,24 @@
  *	fatal_error
  *	Print an error message and terminate the program with code 2.
  */
-void fatal_error (const char *fmt, ...)
+void fatal_error(const char *fmt, ...)
 {
-va_list args;
-va_start (args, fmt);
-print_error_message (fmt, args);
+    va_list args;
+    va_start(args, fmt);
+    print_error_message(fmt, args);
 
 // ... on the other hand, with X, we don't have to
 // call TermGfx() before printing so we do it last so
 // that a segfault occuring in TermGfx() does not
 // prevent us from seeing the stderr message.
-TermGfx ();  // Don't need to sleep (1) either.
+    TermGfx();			// Don't need to sleep (1) either.
 
 // Clean up things and free swap space
-ForgetLevelData ();
-ForgetWTextureNames ();
-ForgetFTextureNames ();
-CloseWadFiles ();
-exit (2);
+    ForgetLevelData();
+    ForgetWTextureNames();
+    ForgetFTextureNames();
+    CloseWadFiles();
+    exit(2);
 }
 
 
@@ -449,12 +457,12 @@
  *	err
  *	Print an error message but do not terminate the program.
  */
-void err (const char *fmt, ...)
+void err(const char *fmt, ...)
 {
-va_list args;
+    va_list args;
 
-va_start (args, fmt);
-print_error_message (fmt, args);
+    va_start(args, fmt);
+    print_error_message(fmt, args);
 }
 
 
@@ -462,20 +470,20 @@
  *	print_error_message
  *	Print an error message to stderr.
  */
-static void print_error_message (const char *fmt, va_list args)
+static void print_error_message(const char *fmt, va_list args)
 {
-fflush (stdout);
-fputs ("Error: ", stderr);
-vfprintf (stderr, fmt, args);
-fputc ('\n', stderr);
-fflush (stderr);
-if (Debug && logfile != NULL)
-   {
-   fputs ("Error: ", logfile);
-   vfprintf (logfile, fmt, args);
-   fputc ('\n', logfile);
-   fflush (logfile);
-   }
+    fflush(stdout);
+    fputs("Error: ", stderr);
+    vfprintf(stderr, fmt, args);
+    fputc('\n', stderr);
+    fflush(stderr);
+    if (Debug && logfile != NULL)
+    {
+	fputs("Error: ", logfile);
+	vfprintf(logfile, fmt, args);
+	fputc('\n', logfile);
+	fflush(logfile);
+    }
 }
 
 
@@ -484,47 +492,48 @@
  *	Report about a non-fatal bug to stderr. The message
  *	should not expand to more than 80 characters.
  */
-void nf_bug (const char *fmt, ...)
+void nf_bug(const char *fmt, ...)
 {
-static bool first_time = 1;
-static int repeats = 0;
-static char msg_prev[81];
-char msg[81];
+    static bool first_time = 1;
+    static int repeats = 0;
+    static char msg_prev[81];
+    char msg[81];
 
-va_list args;
-va_start (args, fmt);
-y_vsnprintf (msg, sizeof msg, fmt, args);
-if (first_time || strncmp (msg, msg_prev, sizeof msg))
-   {
-   fflush (stdout);
-   if (repeats)
-      {
-      fprintf (stderr, "Bug: Previous message repeated %d times\n",
-	    repeats);
-      repeats = 0;
-      }
+    va_list args;
+    va_start(args, fmt);
+    y_vsnprintf(msg, sizeof msg, fmt, args);
+    if (first_time || strncmp(msg, msg_prev, sizeof msg))
+    {
+	fflush(stdout);
+	if (repeats)
+	{
+	    fprintf(stderr, "Bug: Previous message repeated %d times\n",
+		    repeats);
+	    repeats = 0;
+	}
 
-   fprintf (stderr, "Bug: %s\n", msg);
-   fflush (stderr);
-   if (first_time)
-      {
-      fputs ("REPORT ALL \"Bug:\" MESSAGES TO THE MAINTAINER !\n", stderr);
-      first_time = 0;
-      }
-   strncpy (msg_prev, msg, sizeof msg_prev);
-   }
-else
-   {
-   repeats++;  // Same message as above
-   if (repeats == 10)
-      {
-      fflush (stdout);
-      fprintf (stderr, "Bug: Previous message repeated %d times\n",
-	    repeats);
-      fflush (stderr);
-      repeats = 0;
-      }
-   }
+	fprintf(stderr, "Bug: %s\n", msg);
+	fflush(stderr);
+	if (first_time)
+	{
+	    fputs("REPORT ALL \"Bug:\" MESSAGES TO THE MAINTAINER !\n",
+		  stderr);
+	    first_time = 0;
+	}
+	strncpy(msg_prev, msg, sizeof msg_prev);
+    }
+    else
+    {
+	repeats++;		// Same message as above
+	if (repeats == 10)
+	{
+	    fflush(stdout);
+	    fprintf(stderr, "Bug: Previous message repeated %d times\n",
+		    repeats);
+	    fflush(stderr);
+	    repeats = 0;
+	}
+    }
 }
 
 
@@ -532,26 +541,26 @@
    write a message in the log file
 */
 
-void LogMessage (const char *logstr, ...)
+void LogMessage(const char *logstr, ...)
 {
-va_list  args;
-time_t   tval;
-char    *tstr;
+    va_list args;
+    time_t tval;
+    char *tstr;
 
-if (Debug && logfile != NULL)
-   {
-   va_start (args, logstr);
-   /* if the message begins with ":", output the current date & time first */
-   if (logstr[0] == ':')
-      {
-      time (&tval);
-      tstr = ctime (&tval);
-      tstr[strlen (tstr) - 1] = '\0';
-      fprintf (logfile, "%s", tstr);
-      }
-   vfprintf (logfile, logstr, args);
-   fflush (logfile);  /* AYM 19971031 */
-   }
+    if (Debug && logfile != NULL)
+    {
+	va_start(args, logstr);
+	/* if the message begins with ":", output the current date & time first */
+	if (logstr[0] == ':')
+	{
+	    time(&tval);
+	    tstr = ctime(&tval);
+	    tstr[strlen(tstr) - 1] = '\0';
+	    fprintf(logfile, "%s", tstr);
+	}
+	vfprintf(logfile, logstr, args);
+	fflush(logfile);	/* AYM 19971031 */
+    }
 }
 
 
@@ -560,579 +569,580 @@
    the main program menu loop
 */
 
-static void MainLoop ()
+static void MainLoop()
 {
-char input[120];
-char *com, *out;
-FILE *file, *raw;
+    char input[120];
+    char *com, *out;
+    FILE *file, *raw;
 
-for (;;)
-   {
-   /* get the input */
-   printf ("yadex: ");
-   if (! fgets (input, sizeof input, stdin))
-      {
-      puts ("q");
-      break;
-      }
+    for (;;)
+    {
+	/* get the input */
+	printf("yadex: ");
+	if (!fgets(input, sizeof input, stdin))
+	{
+	    puts("q");
+	    break;
+	}
 
-   /* Strip the trailing '\n' */
-   if (strlen (input) > 0 && input[strlen (input) - 1] == '\n')
-      input[strlen (input) - 1] = '\0';
+	/* Strip the trailing '\n' */
+	if (strlen(input) > 0 && input[strlen(input) - 1] == '\n')
+	    input[strlen(input) - 1] = '\0';
 
-   /* eat the white space and get the first command word */
-   com = strtok (input, " ");
+	/* eat the white space and get the first command word */
+	com = strtok(input, " ");
 
-   /* user just hit return */
-   if (com == NULL)
-      printf ("Please enter a command or ? for help.\n");
+	/* user just hit return */
+	if (com == NULL)
+	    printf("Please enter a command or ? for help.\n");
 
-   /* user inputting for help */
-   else if (strcmp (com, "?") == 0
-	 || strcmp (com, "h") == 0
-	 || strcmp (com, "help") == 0)
-      {
-      printf ("? | h | help                      --"
-              " display this text\n");
-      printf ("b[uild] <WadFile>                 --"
-              " build a new iwad\n");
-      printf ("c[reate] <levelname>              --"
-              " create and edit a new (empty) level\n");
-      printf ("d[ump] <DirEntry> [outfile]       --"
-              " dump a directory entry in hex\n");
-      printf ("e[dit] <levelname>                --"
-              " edit a game level saving results to\n");
-      printf ("                                          a patch wad file\n");
-      printf ("g[roup] <WadFile>                 --"
-              " group all patch wads in a file\n");
-      printf ("i[nsert] <RawFile> <DirEntry>     --"
-              " insert a raw file in a patch wad file\n");
-      printf ("l[ist] <WadFile> [outfile]        --"
-              " list the directory of a wadfile\n");
-      printf ("m[aster] [outfile]                --"
-              " list the master directory\n");
-      printf ("make_gimp_palette <outfile>       --"
-              " generate a gimp palette file from\n"
-              "                                    "
-              " entry 0 of lump PLAYPAL.\n");
-      printf ("make_palette_ppm <outfile>        --"
-              " generate a palette image from\n"
-              "                                    "
-              " entry 0 of lump PLAYPAL.\n");
-      printf ("q[uit]                            --"
-              " quit\n");
-      printf ("r[ead] <WadFile>                  --"
-              " read a new wad patch file\n");
-      printf ("s[ave] <DirEntry> <WadFile>       --"
-              " save one object to a separate file\n");
-      printf ("set                               --"
-              " list all options and their values\n");
-      printf ("v[iew] [<spritename>]             --"
-              " display the sprites\n");
-      printf ("viewflat [<flatname>]             --"
-	      " flat viewer\n");
-      printf ("viewpal                           --"
-	      " palette viewer\n");
-      printf ("viewpat [<patchname>]             --"
-	      " patch viewer\n");
-      printf ("viewtex [<texname>]               --"
-	      " texture viewer\n");
-      printf ("w[ads]                            --"
-              " display the open wads\n");
-      printf ("x[tract] <DirEntry> <RawFile>     --"
-              " save (extract) one object to a raw file\n");
-      }
+	/* user inputting for help */
+	else if (strcmp(com, "?") == 0
+		 || strcmp(com, "h") == 0 || strcmp(com, "help") == 0)
+	{
+	    printf("? | h | help                      --"
+		   " display this text\n");
+	    printf("b[uild] <WadFile>                 --"
+		   " build a new iwad\n");
+	    printf("c[reate] <levelname>              --"
+		   " create and edit a new (empty) level\n");
+	    printf("d[ump] <DirEntry> [outfile]       --"
+		   " dump a directory entry in hex\n");
+	    printf("e[dit] <levelname>                --"
+		   " edit a game level saving results to\n");
+	    printf
+		("                                          a patch wad file\n");
+	    printf("g[roup] <WadFile>                 --"
+		   " group all patch wads in a file\n");
+	    printf("i[nsert] <RawFile> <DirEntry>     --"
+		   " insert a raw file in a patch wad file\n");
+	    printf("l[ist] <WadFile> [outfile]        --"
+		   " list the directory of a wadfile\n");
+	    printf("m[aster] [outfile]                --"
+		   " list the master directory\n");
+	    printf("make_gimp_palette <outfile>       --"
+		   " generate a gimp palette file from\n"
+		   "                                    "
+		   " entry 0 of lump PLAYPAL.\n");
+	    printf("make_palette_ppm <outfile>        --"
+		   " generate a palette image from\n"
+		   "                                    "
+		   " entry 0 of lump PLAYPAL.\n");
+	    printf("q[uit]                            --" " quit\n");
+	    printf("r[ead] <WadFile>                  --"
+		   " read a new wad patch file\n");
+	    printf("s[ave] <DirEntry> <WadFile>       --"
+		   " save one object to a separate file\n");
+	    printf("set                               --"
+		   " list all options and their values\n");
+	    printf("v[iew] [<spritename>]             --"
+		   " display the sprites\n");
+	    printf("viewflat [<flatname>]             --" " flat viewer\n");
+	    printf("viewpal                           --"
+		   " palette viewer\n");
+	    printf("viewpat [<patchname>]             --" " patch viewer\n");
+	    printf("viewtex [<texname>]               --"
+		   " texture viewer\n");
+	    printf("w[ads]                            --"
+		   " display the open wads\n");
+	    printf("x[tract] <DirEntry> <RawFile>     --"
+		   " save (extract) one object to a raw file\n");
+	}
 
-   /* user asked for list of open wad files */
-   else if (strcmp (com, "wads") == 0 || strcmp (com, "w") == 0)
-      {
-      const Wad_file *wf;
-      wad_list.rewind ();
-      if (wad_list.get (wf))
-	 printf ("%-40s  Iwad\n", wf->pathname ());
-      while (wad_list.get (wf))
-	 printf ("%-40s  Pwad (%.*s)\n",
-	    wf->pathname (), (int) WAD_NAME, wf->what ());
-      }
-
-   /* user asked to quit */
-   else if (strcmp (com, "quit") == 0 || strcmp (com, "q") == 0)
-      {
-      if (! Registered)
-	 printf ("Remember to register your copy of the game !\n");
-      break;
-      }
+	/* user asked for list of open wad files */
+	else if (strcmp(com, "wads") == 0 || strcmp(com, "w") == 0)
+	{
+	    const Wad_file *wf;
+	    wad_list.rewind();
+	    if (wad_list.get(wf))
+		printf("%-40s  Iwad\n", wf->pathname());
+	    while (wad_list.get(wf))
+		printf("%-40s  Pwad (%.*s)\n",
+		       wf->pathname(), (int) WAD_NAME, wf->what());
+	}
 
-   /* user asked to edit a level */
-   else if (strcmp (com, "edit") == 0 || strcmp (com, "e") == 0
-         || strcmp (com, "create") == 0 || strcmp (com, "c") == 0)
-      {
-      const int newlevel = strcmp (com, "create") == 0
-			|| strcmp (com, "c") == 0;
-      char *level_name = 0;
-      com = strtok (NULL, " ");
-      if (com == 0)
-	 if (! newlevel)
-	    {
-	    printf ("Which level ?\n");
-	    continue;
-	    }
-         else
-	    level_name = 0;
-      else
-	 {
-	 level_name = find_level (com);
-	 if (level_name == error_invalid)
-	    {
-	    printf ("\"%s\" is not a valid level name.\n", com);
-	    continue;
-	    }
-	 else if (level_name == error_none)
-	    {
-	    printf ("Neither E%dM%d nor MAP%02d exist.\n",
-	       atoi (com) / 10, atoi (com) % 10, atoi (com));
-	    continue;
-	    }
-	 else if (level_name == error_non_unique)
-	    {
-	    printf ("Both E%dM%d and MAP%02d exist. Use an unambiguous name.\n",
-	       atoi (com) / 10, atoi (com) % 10, atoi (com));
-	    continue;
-	    }
-	 else if (level_name == NULL)
+	/* user asked to quit */
+	else if (strcmp(com, "quit") == 0 || strcmp(com, "q") == 0)
+	{
+	    if (!Registered)
+		printf("Remember to register your copy of the game !\n");
+	    break;
+	}
+
+	/* user asked to edit a level */
+	else if (strcmp(com, "edit") == 0 || strcmp(com, "e") == 0
+		 || strcmp(com, "create") == 0 || strcmp(com, "c") == 0)
+	{
+	    const int newlevel = strcmp(com, "create") == 0
+		|| strcmp(com, "c") == 0;
+	    char *level_name = 0;
+	    com = strtok(NULL, " ");
+	    if (com == 0)
+		if (!newlevel)
+		{
+		    printf("Which level ?\n");
+		    continue;
+		}
+		else
+		    level_name = 0;
+	    else
 	    {
-	    printf ("Level %s not found.", com);
-	    // Hint absent-minded users
-	    if (tolower (*com) == 'e' && yg_level_name == YGLN_MAP01
-	       || tolower (*com) == 'm' && yg_level_name == YGLN_E1M1)
-	       printf (" You are in %s mode.", Game);
-	    else if (tolower (*com) == 'e' && com[1] > '1' && ! Registered)
-	       printf (" You have the shareware iwad.");
-	    putchar ('\n');
-	    continue;
+		level_name = find_level(com);
+		if (level_name == error_invalid)
+		{
+		    printf("\"%s\" is not a valid level name.\n", com);
+		    continue;
+		}
+		else if (level_name == error_none)
+		{
+		    printf("Neither E%dM%d nor MAP%02d exist.\n",
+			   atoi(com) / 10, atoi(com) % 10, atoi(com));
+		    continue;
+		}
+		else if (level_name == error_non_unique)
+		{
+		    printf
+			("Both E%dM%d and MAP%02d exist. Use an unambiguous name.\n",
+			 atoi(com) / 10, atoi(com) % 10, atoi(com));
+		    continue;
+		}
+		else if (level_name == NULL)
+		{
+		    printf("Level %s not found.", com);
+		    // Hint absent-minded users
+		    if (tolower(*com) == 'e' && yg_level_name == YGLN_MAP01
+			|| tolower(*com) == 'm' && yg_level_name == YGLN_E1M1)
+			printf(" You are in %s mode.", Game);
+		    else if (tolower(*com) == 'e' && com[1] > '1'
+			     && !Registered)
+			printf(" You have the shareware iwad.");
+		    putchar('\n');
+		    continue;
+		}
 	    }
-	 }
-      EditLevel (level_name, newlevel);
-      if (level_name)
-         free (level_name);
-      }
+	    EditLevel(level_name, newlevel);
+	    if (level_name)
+		free(level_name);
+	}
 
-   /* user asked to build a new main wad file */
-   else if (strcmp (com, "build") == 0 || strcmp (com, "b") == 0)
-      {
-      com = strtok (NULL, " ");
-      if (com == NULL)
-	 {
-	 printf ("Wad file name argument missing.\n");
-	 continue;
-	 }
-      if (wad_already_loaded (com))
-	 {
-	 printf ("%s: in use, close it first\n", com);
-	 continue;
-	 }
-      BuildNewMainWad (com, 0);
-      }
+	/* user asked to build a new main wad file */
+	else if (strcmp(com, "build") == 0 || strcmp(com, "b") == 0)
+	{
+	    com = strtok(NULL, " ");
+	    if (com == NULL)
+	    {
+		printf("Wad file name argument missing.\n");
+		continue;
+	    }
+	    if (wad_already_loaded(com))
+	    {
+		printf("%s: in use, close it first\n", com);
+		continue;
+	    }
+	    BuildNewMainWad(com, 0);
+	}
 
-   /* user asked to build a compound patch wad file */
-   else if (strcmp (com, "group") == 0 || strcmp (com, "g") == 0)
-      {
-      wad_list.rewind ();
-      const Wad_file *wf;
-      if (! wad_list.get (wf) || ! wad_list.get (wf))
-	 {
-	 printf ("You need at least two open wad files "
-	   "if you want to group them.\n");
-	 continue;
-	 }
-      com = strtok (NULL, " ");
-      if (com == NULL)
-	 {
-	 printf ("Wad file name argument missing.\n");
-	 continue;
-	 }
-      if (wad_already_loaded (com))
-	 {
-	 printf ("%s: in use, close it first\n", com);
-	 continue;
-	 }
-      BuildNewMainWad (com, 1);
-      }
+	/* user asked to build a compound patch wad file */
+	else if (strcmp(com, "group") == 0 || strcmp(com, "g") == 0)
+	{
+	    wad_list.rewind();
+	    const Wad_file *wf;
+	    if (!wad_list.get(wf) || !wad_list.get(wf))
+	    {
+		printf("You need at least two open wad files "
+		       "if you want to group them.\n");
+		continue;
+	    }
+	    com = strtok(NULL, " ");
+	    if (com == NULL)
+	    {
+		printf("Wad file name argument missing.\n");
+		continue;
+	    }
+	    if (wad_already_loaded(com))
+	    {
+		printf("%s: in use, close it first\n", com);
+		continue;
+	    }
+	    BuildNewMainWad(com, 1);
+	}
 
-   /* user ask for a listing of a wad file */
-   else if (strcmp (com, "list") == 0 || strcmp (com, "l") == 0)
-      {
-      com = strtok (NULL, " ");
-      if (com == NULL)
-	 {
-	 printf ("Wad file name argument missing.\n");
-	 continue;
-	 }
-      const Wad_file *wf = wad_by_name (com);
-      if (wf == 0)
-	 {
-	 printf ("%s: not open\n", com);
-	 continue;
-	 }
-      out = strtok (NULL, " ");
-      if (out)
-	 {
-	 printf ("Outputting directory of \"%s\" to \"%s\".\n",
-	   wf->pathname (), out);
-	 if ((file = fopen (out, "w")) == NULL)
-	    fatal_error ("error opening output file \"%s\"", com);
-	 fprintf (file, "%s\n", what ());
-	 ListFileDirectory (file, wf);
-	 fprintf (file, "\nEnd of file.\n");
-	 fclose (file);
-	 }
-      else
-	 ListFileDirectory (stdout, wf);
-      }
+	/* user ask for a listing of a wad file */
+	else if (strcmp(com, "list") == 0 || strcmp(com, "l") == 0)
+	{
+	    com = strtok(NULL, " ");
+	    if (com == NULL)
+	    {
+		printf("Wad file name argument missing.\n");
+		continue;
+	    }
+	    const Wad_file *wf = wad_by_name(com);
+	    if (wf == 0)
+	    {
+		printf("%s: not open\n", com);
+		continue;
+	    }
+	    out = strtok(NULL, " ");
+	    if (out)
+	    {
+		printf("Outputting directory of \"%s\" to \"%s\".\n",
+		       wf->pathname(), out);
+		if ((file = fopen(out, "w")) == NULL)
+		    fatal_error("error opening output file \"%s\"", com);
+		fprintf(file, "%s\n", what());
+		ListFileDirectory(file, wf);
+		fprintf(file, "\nEnd of file.\n");
+		fclose(file);
+	    }
+	    else
+		ListFileDirectory(stdout, wf);
+	}
 
-   /* user asked for the list of the master directory */
-   else if (strcmp (com, "master") == 0 || strcmp (com, "m") == 0)
-      {
-      out = strtok (NULL, " ");
-      if (out)
-	 {
-	 printf ("Outputting master directory to \"%s\".\n", out);
-	 if ((file = fopen (out, "w")) == NULL)
-	    fatal_error ("error opening output file \"%s\"", com);
-	 fprintf (file, "%s\n", what ());
-	 ListMasterDirectory (file);
-	 fprintf (file, "\nEnd of file.\n");
-	 fclose (file);
-	 }
-      else
-	 ListMasterDirectory (stdout);
-      }
+	/* user asked for the list of the master directory */
+	else if (strcmp(com, "master") == 0 || strcmp(com, "m") == 0)
+	{
+	    out = strtok(NULL, " ");
+	    if (out)
+	    {
+		printf("Outputting master directory to \"%s\".\n", out);
+		if ((file = fopen(out, "w")) == NULL)
+		    fatal_error("error opening output file \"%s\"", com);
+		fprintf(file, "%s\n", what());
+		ListMasterDirectory(file);
+		fprintf(file, "\nEnd of file.\n");
+		fclose(file);
+	    }
+	    else
+		ListMasterDirectory(stdout);
+	}
 
-   // make_gimp_palette
-   else if (strcmp (com, "make_gimp_palette") == 0)
-      {
-      out = strtok (NULL, " ");
-      if (out == NULL)
-         {
-         printf ("Output file name argument missing.\n");
-         continue;
-         }
-      make_gimp_palette (0, out);
-      }
+	// make_gimp_palette
+	else if (strcmp(com, "make_gimp_palette") == 0)
+	{
+	    out = strtok(NULL, " ");
+	    if (out == NULL)
+	    {
+		printf("Output file name argument missing.\n");
+		continue;
+	    }
+	    make_gimp_palette(0, out);
+	}
 
-   // make_palette_ppm
-   else if (strcmp (com, "make_palette_ppm") == 0)
-      {
-      out = strtok (NULL, "");
-      if (out == NULL)
-	 {
-	 printf ("Output file name argument missing.\n");
-	 continue;
-	 }
-      make_palette_ppm (0, out);
-      }
+	// make_palette_ppm
+	else if (strcmp(com, "make_palette_ppm") == 0)
+	{
+	    out = strtok(NULL, "");
+	    if (out == NULL)
+	    {
+		printf("Output file name argument missing.\n");
+		continue;
+	    }
+	    make_palette_ppm(0, out);
+	}
 
-   // make_palette_ppm
-   else if (strcmp (com, "mp2") == 0)
-      {
-      out = strtok (NULL, "");
-      if (out == NULL)
-	 {
-	 printf ("Output file name argument missing.\n");
-	 continue;
-	 }
-      make_palette_ppm_2 (0, out);
-      }
+	// make_palette_ppm
+	else if (strcmp(com, "mp2") == 0)
+	{
+	    out = strtok(NULL, "");
+	    if (out == NULL)
+	    {
+		printf("Output file name argument missing.\n");
+		continue;
+	    }
+	    make_palette_ppm_2(0, out);
+	}
 
-   /* user asked to list all options and their values */
-   else if (strcmp (com, "set") == 0)
-      {
-      dump_parameters (stdout);
-      }
+	/* user asked to list all options and their values */
+	else if (strcmp(com, "set") == 0)
+	{
+	    dump_parameters(stdout);
+	}
 
-   /* user asked to read a new patch wad file */
-   else if (strcmp (com, "read") == 0 || strcmp (com, "r") == 0)
-      {
-      com = strtok (NULL, " ");
-      if (com == NULL)
-	 {
-	 printf ("Wad file name argument missing.\n");
-	 continue;
-	 }
-      out = strtok (NULL, " ");
-      if (out)
-	*out = '\0';
-      out = (char *) GetMemory (strlen (com) + 1);
-      strcpy (out, com);
-      OpenPatchWad (out);
-      CloseUnusedWadFiles ();
-      }
+	/* user asked to read a new patch wad file */
+	else if (strcmp(com, "read") == 0 || strcmp(com, "r") == 0)
+	{
+	    com = strtok(NULL, " ");
+	    if (com == NULL)
+	    {
+		printf("Wad file name argument missing.\n");
+		continue;
+	    }
+	    out = strtok(NULL, " ");
+	    if (out)
+		*out = '\0';
+	    out = (char *) GetMemory(strlen(com) + 1);
+	    strcpy(out, com);
+	    OpenPatchWad(out);
+	    CloseUnusedWadFiles();
+	}
 
-   /* user asked to dump the contents of a wad file */
-   else if (strcmp (com, "dump") == 0 || strcmp (com, "d") == 0)
-      {
-      com = strtok (NULL, " ");
-      if (com == NULL)
-	 {
-	 printf ("Object name argument missing.\n");
-	 continue;
-	 }
-      out = strtok (NULL, " ");
-      if (out)
-	 {
-	 printf ("Outputting directory entry data to \"%s\".\n", out);
-	 if ((file = fopen (out, "w")) == NULL)
-	    fatal_error ("error opening output file \"%s\"", com);
-	 fprintf (file, "%s\n", what ());
-	 DumpDirectoryEntry (file, com);
-	 fprintf (file, "\nEnd of file.\n");
-	 fclose (file);
-	 }
-      else
-	 DumpDirectoryEntry (stdout, com);
-      }
+	/* user asked to dump the contents of a wad file */
+	else if (strcmp(com, "dump") == 0 || strcmp(com, "d") == 0)
+	{
+	    com = strtok(NULL, " ");
+	    if (com == NULL)
+	    {
+		printf("Object name argument missing.\n");
+		continue;
+	    }
+	    out = strtok(NULL, " ");
+	    if (out)
+	    {
+		printf("Outputting directory entry data to \"%s\".\n", out);
+		if ((file = fopen(out, "w")) == NULL)
+		    fatal_error("error opening output file \"%s\"", com);
+		fprintf(file, "%s\n", what());
+		DumpDirectoryEntry(file, com);
+		fprintf(file, "\nEnd of file.\n");
+		fclose(file);
+	    }
+	    else
+		DumpDirectoryEntry(stdout, com);
+	}
 
-   // "v"/"view" - view the sprites
-   else if (strcmp (com, "view") == 0 || strcmp (com, "v") == 0)
-      {
-      if (InitGfx ())
-	 goto v_end;
-      init_input_status ();
-      do
-	 get_input_status ();
-      while (is.key != YE_EXPOSE);
-      force_window_not_pixmap ();  // FIXME quick hack
-      {
-      Lump_list list;
-      wad_res.sprites.list (list);
-      char buf[WAD_PIC_NAME + 1];
-      const char *sprite = strtok (NULL, " ");
-      *buf = '\0';
-      if (sprite != 0)
-      {
-	strncat (buf, sprite, sizeof buf - 1);
-	for (char *p = buf; *p != '\0'; p++)
-	  *p = toupper (*p);
-      }
-      InputNameFromListWithFunc (-1, -1, "Sprite viewer", list.size (),
-	list.data (), 10, buf, 320, 200, display_pic,
-	HOOK_DISP_SIZE | HOOK_SPRITE);
-      }
-      TermGfx ();
-      v_end:;
-      }
+	// "v"/"view" - view the sprites
+	else if (strcmp(com, "view") == 0 || strcmp(com, "v") == 0)
+	{
+	    if (InitGfx())
+		goto v_end;
+	    init_input_status();
+	    do
+		get_input_status();
+	    while (is.key != YE_EXPOSE);
+	    force_window_not_pixmap();	// FIXME quick hack
+	    {
+		Lump_list list;
+		wad_res.sprites.list(list);
+		char buf[WAD_PIC_NAME + 1];
+		const char *sprite = strtok(NULL, " ");
+		*buf = '\0';
+		if (sprite != 0)
+		{
+		    strncat(buf, sprite, sizeof buf - 1);
+		    for (char *p = buf; *p != '\0'; p++)
+			*p = toupper(*p);
+		}
+		InputNameFromListWithFunc(-1, -1, "Sprite viewer",
+					  list.size(), list.data(), 10, buf,
+					  320, 200, display_pic,
+					  HOOK_DISP_SIZE | HOOK_SPRITE);
+	    }
+	    TermGfx();
+	  v_end:;
+	}
 
-   // "viewflat" - view the flats
-   else if (strcmp (com, "viewflat") == 0)
-      {
-      if (InitGfx ())
-	goto viewflat_end;
-      init_input_status ();
-      do
-	 get_input_status ();
-      while (is.key != YE_EXPOSE);
-      com = strtok (NULL, " ");
-      force_window_not_pixmap ();  // FIXME quick hack
-      char buf[WAD_FLAT_NAME + 1];
-      *buf = '\0';
-      if (com != 0)
-	strncat (buf, com, sizeof buf - 1);
-      ReadFTextureNames ();
-      {
-      char **flat_names =
-	(char **) GetMemory (NumFTexture * sizeof *flat_names);
-      for (size_t n = 0; n < NumFTexture; n++)
-	flat_names[n] = flat_list[n].name;
-      ChooseFloorTexture (-1, -1, "Flat viewer",
-	NumFTexture, flat_names, buf);
-      FreeMemory (flat_names);
-      }
-      ForgetFTextureNames ();
-      TermGfx ();
-      viewflat_end:;
-      }
+	// "viewflat" - view the flats
+	else if (strcmp(com, "viewflat") == 0)
+	{
+	    if (InitGfx())
+		goto viewflat_end;
+	    init_input_status();
+	    do
+		get_input_status();
+	    while (is.key != YE_EXPOSE);
+	    com = strtok(NULL, " ");
+	    force_window_not_pixmap();	// FIXME quick hack
+	    char buf[WAD_FLAT_NAME + 1];
+	    *buf = '\0';
+	    if (com != 0)
+		strncat(buf, com, sizeof buf - 1);
+	    ReadFTextureNames();
+	    {
+		char **flat_names =
+		    (char **) GetMemory(NumFTexture * sizeof *flat_names);
+		for (size_t n = 0; n < NumFTexture; n++)
+		    flat_names[n] = flat_list[n].name;
+		ChooseFloorTexture(-1, -1, "Flat viewer",
+				   NumFTexture, flat_names, buf);
+		FreeMemory(flat_names);
+	    }
+	    ForgetFTextureNames();
+	    TermGfx();
+	  viewflat_end:;
+	}
+
+	// "viewpal" - view the palette (PLAYPAL and COLORMAP)
+	else if (strcmp(com, "viewpal") == 0)
+	{
+	    if (InitGfx())
+		goto viewpal_end;
+	    init_input_status();
+	    do
+		get_input_status();
+	    while (is.key != YE_EXPOSE);
+	    force_window_not_pixmap();	// FIXME quick hack
+	    {
+		Palette_viewer pv;
+		pv.run();
+	    }
+	    TermGfx();
+	  viewpal_end:;
+	}
 
-   // "viewpal" - view the palette (PLAYPAL and COLORMAP)
-   else if (strcmp (com, "viewpal") == 0)
-      {
-      if (InitGfx ())
-	goto viewpal_end;
-      init_input_status ();
-      do
-	 get_input_status ();
-      while (is.key != YE_EXPOSE);
-      force_window_not_pixmap ();  // FIXME quick hack
-      {
-      Palette_viewer pv;
-      pv.run ();
-      }
-      TermGfx ();
-      viewpal_end:;
-      }
-   
-   // "viewpat" - view the patches
-   else if (strcmp (com, "viewpat") == 0)
-      {
-      if (InitGfx ())
-	goto viewpat_end;
-      init_input_status ();
-      do
-	 get_input_status ();
-      while (is.key != YE_EXPOSE);
-      com = strtok (NULL, " ");
-      force_window_not_pixmap ();  // FIXME quick hack
-      patch_dir.refresh (MasterDir);
-      {
-	 char buf[WAD_NAME + 1];
-	 *buf = '\0';
-	 if (com != 0)
-	   strncat (buf, com, sizeof buf - 1);
-	 Patch_list pl;
-	 patch_dir.list (pl);
-	 InputNameFromListWithFunc (-1, -1, "Patch viewer", pl.size (),
-	       pl.data (), 10, buf, 256, 256, display_pic,
-	       HOOK_DISP_SIZE | HOOK_PATCH);
-      }
-      TermGfx ();
-      viewpat_end:;
-      }
+	// "viewpat" - view the patches
+	else if (strcmp(com, "viewpat") == 0)
+	{
+	    if (InitGfx())
+		goto viewpat_end;
+	    init_input_status();
+	    do
+		get_input_status();
+	    while (is.key != YE_EXPOSE);
+	    com = strtok(NULL, " ");
+	    force_window_not_pixmap();	// FIXME quick hack
+	    patch_dir.refresh(MasterDir);
+	    {
+		char buf[WAD_NAME + 1];
+		*buf = '\0';
+		if (com != 0)
+		    strncat(buf, com, sizeof buf - 1);
+		Patch_list pl;
+		patch_dir.list(pl);
+		InputNameFromListWithFunc(-1, -1, "Patch viewer", pl.size(),
+					  pl.data(), 10, buf, 256, 256,
+					  display_pic,
+					  HOOK_DISP_SIZE | HOOK_PATCH);
+	    }
+	    TermGfx();
+	  viewpat_end:;
+	}
 
-   // "viewtex" - view the textures
-   else if (strcmp (com, "viewtex") == 0)
-      {
-      if (InitGfx ())
-	goto viewtex_end;
-      init_input_status ();
-      do
-	 get_input_status ();
-      while (is.key != YE_EXPOSE);
-      com = strtok (NULL, " ");
-      force_window_not_pixmap ();  // FIXME quick hack
-      patch_dir.refresh (MasterDir);
-      {
-	 char buf[WAD_TEX_NAME + 1];
-	 *buf = '\0';
-	 if (com != 0)
-	   strncat (buf, com, sizeof buf - 1);
-	 ReadWTextureNames ();
-	 ChooseWallTexture (-1, -1, "Texture viewer", NumWTexture, WTexture,
-	   buf);
-	 ForgetWTextureNames ();
-      }
-      TermGfx ();
-      viewtex_end:;
-      }
+	// "viewtex" - view the textures
+	else if (strcmp(com, "viewtex") == 0)
+	{
+	    if (InitGfx())
+		goto viewtex_end;
+	    init_input_status();
+	    do
+		get_input_status();
+	    while (is.key != YE_EXPOSE);
+	    com = strtok(NULL, " ");
+	    force_window_not_pixmap();	// FIXME quick hack
+	    patch_dir.refresh(MasterDir);
+	    {
+		char buf[WAD_TEX_NAME + 1];
+		*buf = '\0';
+		if (com != 0)
+		    strncat(buf, com, sizeof buf - 1);
+		ReadWTextureNames();
+		ChooseWallTexture(-1, -1, "Texture viewer", NumWTexture,
+				  WTexture, buf);
+		ForgetWTextureNames();
+	    }
+	    TermGfx();
+	  viewtex_end:;
+	}
 
-   /* user asked to save an object to a separate pwad file */
-   else if (strcmp (com, "save") == 0 || strcmp (com, "s") == 0)
-      {
-      com = strtok (NULL, " ");
-      if (com == NULL)
-	 {
-	 printf ("Object name argument missing.\n");
-	 continue;
-	 }
-      if (strlen (com) > WAD_NAME || strchr (com, '.') != NULL)
-	 {
-	 printf ("Invalid object name.\n");
-	 continue;
-	 }
-      out = strtok (NULL, " ");
-      if (out == NULL)
-	 {
-	 printf ("Wad file name argument missing.\n");
-	 continue;
-	 }
-      if (wad_already_loaded (com))
-	 {
-	 printf ("%s: in use, close it first\n", com);
-	 continue;
-	 }
-      printf ("Saving directory entry data to \"%s\".\n", out);
-      if ((file = fopen (out, "wb")) == NULL)
-	 fatal_error ("error opening output file \"%s\"", out);
-      SaveDirectoryEntry (file, com);
-      fclose (file);
-      }
+	/* user asked to save an object to a separate pwad file */
+	else if (strcmp(com, "save") == 0 || strcmp(com, "s") == 0)
+	{
+	    com = strtok(NULL, " ");
+	    if (com == NULL)
+	    {
+		printf("Object name argument missing.\n");
+		continue;
+	    }
+	    if (strlen(com) > WAD_NAME || strchr(com, '.') != NULL)
+	    {
+		printf("Invalid object name.\n");
+		continue;
+	    }
+	    out = strtok(NULL, " ");
+	    if (out == NULL)
+	    {
+		printf("Wad file name argument missing.\n");
+		continue;
+	    }
+	    if (wad_already_loaded(com))
+	    {
+		printf("%s: in use, close it first\n", com);
+		continue;
+	    }
+	    printf("Saving directory entry data to \"%s\".\n", out);
+	    if ((file = fopen(out, "wb")) == NULL)
+		fatal_error("error opening output file \"%s\"", out);
+	    SaveDirectoryEntry(file, com);
+	    fclose(file);
+	}
 
-   /* user asked to encapsulate a raw file in a pwad file */
-   else if (strcmp (com, "insert") == 0 || strcmp (com, "i") == 0)
-      {
-      com = strtok (NULL, " ");
-      if (com == NULL)
-	 {
-	 printf ("Raw file name argument missing.\n");
-	 continue;
-	 }
-      out = strtok (NULL, " ");
-      if (out == NULL)
-	 {
-	 printf ("Object name argument missing.\n");
-	 continue;
-	 }
-      if (strlen (out) > WAD_NAME || strchr (out, '.') != NULL)
-	 {
-	 printf ("Invalid object name.\n");
-	 continue;
-	 }
-      if ((raw = fopen (com, "rb")) == NULL)
-	 fatal_error ("error opening input file \"%s\"", com);
-      /* kluge */
-      strcpy (input, out);
-      strcat (input, ".wad");
-      if (wad_already_loaded (input))
-	 {
-	 printf ("%s: in use, close it first\n", input);
-	 continue;
-	 }
-      printf ("Including new object %s in \"%s\".\n", out, input);
-      if ((file = fopen (input, "wb")) == NULL)
-	 fatal_error ("error opening output file \"%s\"", input);
-      SaveEntryFromRawFile (file, raw, out);
-      fclose (raw);
-      fclose (file);
-      }
+	/* user asked to encapsulate a raw file in a pwad file */
+	else if (strcmp(com, "insert") == 0 || strcmp(com, "i") == 0)
+	{
+	    com = strtok(NULL, " ");
+	    if (com == NULL)
+	    {
+		printf("Raw file name argument missing.\n");
+		continue;
+	    }
+	    out = strtok(NULL, " ");
+	    if (out == NULL)
+	    {
+		printf("Object name argument missing.\n");
+		continue;
+	    }
+	    if (strlen(out) > WAD_NAME || strchr(out, '.') != NULL)
+	    {
+		printf("Invalid object name.\n");
+		continue;
+	    }
+	    if ((raw = fopen(com, "rb")) == NULL)
+		fatal_error("error opening input file \"%s\"", com);
+	    /* kluge */
+	    strcpy(input, out);
+	    strcat(input, ".wad");
+	    if (wad_already_loaded(input))
+	    {
+		printf("%s: in use, close it first\n", input);
+		continue;
+	    }
+	    printf("Including new object %s in \"%s\".\n", out, input);
+	    if ((file = fopen(input, "wb")) == NULL)
+		fatal_error("error opening output file \"%s\"", input);
+	    SaveEntryFromRawFile(file, raw, out);
+	    fclose(raw);
+	    fclose(file);
+	}
 
-   /* user asked to extract an object to a raw binary file */
-   else if (strcmp (com, "xtract") == 0
-	 || strcmp (com, "extract") == 0
-	 || strcmp (com, "x") == 0)
-      {
-      com = strtok (NULL, " ");
-      if (com == NULL)
-	 {
-	 printf ("Object name argument missing.\n");
-	 continue;
-	 }
-      if (strlen (com) > WAD_NAME || strchr (com, '.') != NULL)
-	 {
-	 printf ("Invalid object name.\n");
-	 continue;
-	 }
-      out = strtok (NULL, " ");
-      if (out == NULL)
-	 {
-	 printf ("Raw file name argument missing.\n");
-	 continue;
-	 }
-      if (wad_already_loaded (com))
-	 {
-	 printf ("%s: in use, close it first\n", com);
-	 printf ("Besides do you really want to overwrite a wad file with"
-		 " raw data ?\n");
-	 continue;
-	 }
-      printf ("Saving directory entry data to \"%s\".\n", out);
-      if ((file = fopen (out, "wb")) == NULL)
-	 fatal_error ("error opening output file \"%s\"", out);
-      SaveEntryToRawFile (file, com);
-      fclose (file);
-      }
+	/* user asked to extract an object to a raw binary file */
+	else if (strcmp(com, "xtract") == 0
+		 || strcmp(com, "extract") == 0 || strcmp(com, "x") == 0)
+	{
+	    com = strtok(NULL, " ");
+	    if (com == NULL)
+	    {
+		printf("Object name argument missing.\n");
+		continue;
+	    }
+	    if (strlen(com) > WAD_NAME || strchr(com, '.') != NULL)
+	    {
+		printf("Invalid object name.\n");
+		continue;
+	    }
+	    out = strtok(NULL, " ");
+	    if (out == NULL)
+	    {
+		printf("Raw file name argument missing.\n");
+		continue;
+	    }
+	    if (wad_already_loaded(com))
+	    {
+		printf("%s: in use, close it first\n", com);
+		printf
+		    ("Besides do you really want to overwrite a wad file with"
+		     " raw data ?\n");
+		continue;
+	    }
+	    printf("Saving directory entry data to \"%s\".\n", out);
+	    if ((file = fopen(out, "wb")) == NULL)
+		fatal_error("error opening output file \"%s\"", out);
+	    SaveEntryToRawFile(file, com);
+	    fclose(file);
+	}
 
-   /* unknown command */
-   else
-      printf ("Unknown command \"%s\"!\n", com);
-   }
+	/* unknown command */
+	else
+	    printf("Unknown command \"%s\"!\n", com);
+    }
 }
 
 
@@ -1141,138 +1151,186 @@
  *	Add the NCOLOURS base colours to the list of
  *	application colours.
  */
-static void add_base_colours ()
+static void add_base_colours()
 {
-for (size_t n = 0; n < NCOLOURS; n++)
-   {
-   rgb_c c;
+    for (size_t n = 0; n < NCOLOURS; n++)
+    {
+	rgb_c c;
 
-   // The first 16 are the standard IRGB VGA colours.
-   // FIXME they're to be removed and replaced by
-   // "logical" colours.
+	// The first 16 are the standard IRGB VGA colours.
+	// FIXME they're to be removed and replaced by
+	// "logical" colours.
 #ifdef WHITE_BACKGROUND
-   if (n == 0)
-      irgb2rgb (15, &c);
-   else if (n == 15)
-      irgb2rgb (0, &c);
-   else
+	if (n == 0)
+	    irgb2rgb(15, &c);
+	else if (n == 15)
+	    irgb2rgb(0, &c);
+	else
 #endif
-      if (n < 16)
-      irgb2rgb (n, &c);
+	if (n < 16)
+	    irgb2rgb(n, &c);
 
-   // Then there are the colours used to draw the
-   // windows and the map. The colours used to draw
-   // the things are parametrized in the .ygd ; they
-   // are added by load_game().
-   // FIXME they should not be hard-coded, of course !
+	// Then there are the colours used to draw the
+	// windows and the map. The colours used to draw
+	// the things are parametrized in the .ygd ; they
+	// are added by load_game().
+	// FIXME they should not be hard-coded, of course !
 
-   /* WINBG* is for window backgrounds. Use the _HL variant is
-      for highlighted parts of windows (E.G. the current line in
-      a menu). _LIGHT and _DARK are for window borders and
-      grooves. There is no _HL flavour of these because I didn't
-      feel the need. */
+	/* WINBG* is for window backgrounds. Use the _HL variant is
+	   for highlighted parts of windows (E.G. the current line in
+	   a menu). _LIGHT and _DARK are for window borders and
+	   grooves. There is no _HL flavour of these because I didn't
+	   feel the need. */
 #ifdef WHITE_BACKGROUND
-   else if (n == WINBG)			c.set (0xe2, 0xdc, 0xd6);
-   else if (n == WINBG_LIGHT)		c.set (0xee, 0xe8, 0xe2);
-   else if (n == WINBG_DARK)		c.set (0xc3, 0xbe, 0xb9);
-   else if (n == WINBG_HL)		c.set (0xf4, 0xee, 0xe7);
+	else if (n == WINBG)
+	    c.set(0xe2, 0xdc, 0xd6);
+	else if (n == WINBG_LIGHT)
+	    c.set(0xee, 0xe8, 0xe2);
+	else if (n == WINBG_DARK)
+	    c.set(0xc3, 0xbe, 0xb9);
+	else if (n == WINBG_HL)
+	    c.set(0xf4, 0xee, 0xe7);
 #else
-   else if (n == WINBG)			c.set (0x2a, 0x24, 0x18);
-   else if (n == WINBG_LIGHT)		c.set (0x48, 0x42, 0x3c);
-   else if (n == WINBG_DARK)		c.set (0x20, 0x1b, 0x12);
-   else if (n == WINBG_HL)		c.set (0x58, 0x50, 0x48);
+	else if (n == WINBG)
+	    c.set(0x2a, 0x24, 0x18);
+	else if (n == WINBG_LIGHT)
+	    c.set(0x48, 0x42, 0x3c);
+	else if (n == WINBG_DARK)
+	    c.set(0x20, 0x1b, 0x12);
+	else if (n == WINBG_HL)
+	    c.set(0x58, 0x50, 0x48);
 #endif
 
-   /* WINFG* is for regular text. _DIM is for greyed out text
-      (for disabled options or text that is not applicable). */
+	/* WINFG* is for regular text. _DIM is for greyed out text
+	   (for disabled options or text that is not applicable). */
 #ifdef WHITE_BACKGROUND
-   else if (n == WINFG)			c.set (0x60, 0x60, 0x60);
-   else if (n == WINFG_HL)		c.set (0x30, 0x30, 0x30);
-   else if (n == WINFG_DIM)		c.set (0xB8, 0xB8, 0xB8);
-   else if (n == WINFG_DIM_HL)		c.set (0x90, 0x90, 0x90);
+	else if (n == WINFG)
+	    c.set(0x60, 0x60, 0x60);
+	else if (n == WINFG_HL)
+	    c.set(0x30, 0x30, 0x30);
+	else if (n == WINFG_DIM)
+	    c.set(0xB8, 0xB8, 0xB8);
+	else if (n == WINFG_DIM_HL)
+	    c.set(0x90, 0x90, 0x90);
 #else
-   else if (n == WINFG)			c.set (0xa0, 0xa0, 0xa0);
-   else if (n == WINFG_HL)		c.set (0xd0, 0xd0, 0xd0);
-   else if (n == WINFG_DIM)		c.set (0x48, 0x48, 0x48);
-   else if (n == WINFG_DIM_HL)		c.set (0x70, 0x70, 0x70);
+	else if (n == WINFG)
+	    c.set(0xa0, 0xa0, 0xa0);
+	else if (n == WINFG_HL)
+	    c.set(0xd0, 0xd0, 0xd0);
+	else if (n == WINFG_DIM)
+	    c.set(0x48, 0x48, 0x48);
+	else if (n == WINFG_DIM_HL)
+	    c.set(0x70, 0x70, 0x70);
 #endif
 
-   /* WINLABEL is for text of lesser importance. For example,
-      the brackets around key binding are displayed in WINLABEL,
-      while what's between them is displayed in WINFG. The
-      difference with WINFG is not very noticeable but it does
-      improve readability. The static text in the object info
-      windows should be displayed in WINLABEL. */
+	/* WINLABEL is for text of lesser importance. For example,
+	   the brackets around key binding are displayed in WINLABEL,
+	   while what's between them is displayed in WINFG. The
+	   difference with WINFG is not very noticeable but it does
+	   improve readability. The static text in the object info
+	   windows should be displayed in WINLABEL. */
 #ifdef WHITE_BACKGROUND
-   else if (n == WINLABEL)		c.set (0x88, 0x88, 0x88);
-   else if (n == WINLABEL_HL)		c.set (0x60, 0x60, 0x60);
-   else if (n == WINLABEL_DIM)		c.set (0xc8, 0xc8, 0xc8);
-   else if (n == WINLABEL_DIM_HL)	c.set (0xb0, 0xb0, 0xb0);
+	else if (n == WINLABEL)
+	    c.set(0x88, 0x88, 0x88);
+	else if (n == WINLABEL_HL)
+	    c.set(0x60, 0x60, 0x60);
+	else if (n == WINLABEL_DIM)
+	    c.set(0xc8, 0xc8, 0xc8);
+	else if (n == WINLABEL_DIM_HL)
+	    c.set(0xb0, 0xb0, 0xb0);
 #else
-   else if (n == WINLABEL)		c.set (0x78, 0x78, 0x78);
-   else if (n == WINLABEL_HL)		c.set (0xa0, 0xa0, 0xa0);
-   else if (n == WINLABEL_DIM)		c.set (0x38, 0x38, 0x38);
-   else if (n == WINLABEL_DIM_HL)	c.set (0x50, 0x50, 0x50);
+	else if (n == WINLABEL)
+	    c.set(0x78, 0x78, 0x78);
+	else if (n == WINLABEL_HL)
+	    c.set(0xa0, 0xa0, 0xa0);
+	else if (n == WINLABEL_DIM)
+	    c.set(0x38, 0x38, 0x38);
+	else if (n == WINLABEL_DIM_HL)
+	    c.set(0x50, 0x50, 0x50);
 #endif
 
 #ifdef WHITE_BACKGROUND
-   else if (n == GRID1)			c.set (0x80, 0x80, 0xff);
-   else if (n == GRID2H)		c.set (0xf0, 0xf0, 0xff);
-   else if (n == GRID2V)		c.set (0xf0, 0xf0, 0xff);
-   else if (n == GRID3H)		c.set (0xd0, 0xd0, 0xff);
-   else if (n == GRID3V)		c.set (0xd0, 0xd0, 0xff);
-   else if (n == GRID4H)		c.set (0xb0, 0xb0, 0xff);
-   else if (n == GRID4V)		c.set (0xb0, 0xb0, 0xff);
+	else if (n == GRID1)
+	    c.set(0x80, 0x80, 0xff);
+	else if (n == GRID2H)
+	    c.set(0xf0, 0xf0, 0xff);
+	else if (n == GRID2V)
+	    c.set(0xf0, 0xf0, 0xff);
+	else if (n == GRID3H)
+	    c.set(0xd0, 0xd0, 0xff);
+	else if (n == GRID3V)
+	    c.set(0xd0, 0xd0, 0xff);
+	else if (n == GRID4H)
+	    c.set(0xb0, 0xb0, 0xff);
+	else if (n == GRID4V)
+	    c.set(0xb0, 0xb0, 0xff);
 #else
-   else if (n == GRID1)			c.set (0, 0, 0xc0);
-   else if (n == GRID2H)		c.set (0, 0, 0x30);
-   else if (n == GRID2V)		c.set (0, 0, 0x40);
-   else if (n == GRID3H)		c.set (0, 0, 0x50);
-   else if (n == GRID3V)		c.set (0, 0, 0x70);
-   else if (n == GRID4H)		c.set (0, 0, 0x80);
-   else if (n == GRID4V)		c.set (0, 0, 0xc0);
+	else if (n == GRID1)
+	    c.set(0, 0, 0xc0);
+	else if (n == GRID2H)
+	    c.set(0, 0, 0x30);
+	else if (n == GRID2V)
+	    c.set(0, 0, 0x40);
+	else if (n == GRID3H)
+	    c.set(0, 0, 0x50);
+	else if (n == GRID3V)
+	    c.set(0, 0, 0x70);
+	else if (n == GRID4H)
+	    c.set(0, 0, 0x80);
+	else if (n == GRID4V)
+	    c.set(0, 0, 0xc0);
 #endif
 
-   else if (n == LINEDEF_NO)		c.set (0x40, 0xd0, 0xf0);
-   else if (n == SECTOR_NO)		c.set (0x40, 0xd0, 0xf0);
-   else if (n == THING_NO)		c.set (0x40, 0xd0, 0xf0);
-   else if (n == VERTEX_NO)		c.set (0x40, 0xd0, 0xf0);
-   else if (n == CLR_ERROR)		c.set (0xff, 0,    0);
-   else if (n == THING_REM)		c.set (0x40, 0x40, 0x40);
+	else if (n == LINEDEF_NO)
+	    c.set(0x40, 0xd0, 0xf0);
+	else if (n == SECTOR_NO)
+	    c.set(0x40, 0xd0, 0xf0);
+	else if (n == THING_NO)
+	    c.set(0x40, 0xd0, 0xf0);
+	else if (n == VERTEX_NO)
+	    c.set(0x40, 0xd0, 0xf0);
+	else if (n == CLR_ERROR)
+	    c.set(0xff, 0, 0);
+	else if (n == THING_REM)
+	    c.set(0x40, 0x40, 0x40);
 
-   else if (n == SECTOR_TAG)		c.set (0x00, 0xff, 0x00);
-   else if (n == SECTOR_TAGTYPE)	c.set (0x00, 0xe0, 0xe0);
-   else if (n == SECTOR_TYPE)		c.set (0x00, 0x80, 0xff);
+	else if (n == SECTOR_TAG)
+	    c.set(0x00, 0xff, 0x00);
+	else if (n == SECTOR_TAGTYPE)
+	    c.set(0x00, 0xe0, 0xe0);
+	else if (n == SECTOR_TYPE)
+	    c.set(0x00, 0x80, 0xff);
 
 #ifdef WHITE_BACKGROUND
-   else if (n == WINTITLE)		c.set (0xb0, 0x80, 0x00);
+	else if (n == WINTITLE)
+	    c.set(0xb0, 0x80, 0x00);
 #else
-   else if (n == WINTITLE)		c.set (0xff, 0xff, 0x00);
+	else if (n == WINTITLE)
+	    c.set(0xff, 0xff, 0x00);
 #endif
 
-   else					fatal_error ("Wrong acn %d", n);
+	else
+	    fatal_error("Wrong acn %d", n);
 
-   acolour_t acn = add_app_colour (c);
-   if (acn != n)
-      fatal_error ("add_base_colours: got %d for %d\n", acn, n);
-   }
+	acolour_t acn = add_app_colour(c);
+	if (acn != n)
+	    fatal_error("add_base_colours: got %d for %d\n", acn, n);
+    }
 }
 
 
-static const Wad_file *wad_by_name (const char *pathname)
+static const Wad_file *wad_by_name(const char *pathname)
 {
-  const Wad_file *wf;
+    const Wad_file *wf;
 
-  for (wad_list.rewind (); wad_list.get (wf);)
-    if (fncmp (pathname, wf->pathname ()) == 0)
-      return wf;
-  return 0;
+    for (wad_list.rewind(); wad_list.get(wf);)
+	if (fncmp(pathname, wf->pathname()) == 0)
+	    return wf;
+    return 0;
 }
 
 
-static bool wad_already_loaded (const char *pathname)
+static bool wad_already_loaded(const char *pathname)
 {
-  return wad_by_name (pathname) != 0;
+    return wad_by_name(pathname) != 0;
 }
-
-
--- a/src/yadex.h	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/yadex.h	Sat Sep 24 14:16:04 2011 +0300
@@ -28,7 +28,7 @@
 */
 
 
-#ifndef YH_YADEX  /* DO NOT INSERT ANYTHING BEFORE THIS LINE */
+#ifndef YH_YADEX		/* DO NOT INSERT ANYTHING BEFORE THIS LINE */
 #define YH_YADEX
 
 
@@ -58,9 +58,9 @@
  *	Additional libraries
  */
 #include <atclib.h>
-#include "bitvec.h"  /* bv_set, bv_clear, bv_toggle */
+#include "bitvec.h"		/* bv_set, bv_clear, bv_toggle */
 #include "yerror.h"
-#include "aym.h"     /* Needs yerror.h */
+#include "aym.h"		/* Needs yerror.h */
 #include "windim.h"
 #include "ymemory.h"
 
@@ -68,22 +68,22 @@
 /*
  *	Platform-independant types and formats.
  */
-typedef unsigned char  u8;
-typedef signed   char  i8;
+typedef unsigned char u8;
+typedef signed char i8;
 
 typedef unsigned short u16;
 #define F_U16_D "hu"
 #define F_U16_H "hX"
 
-typedef signed   short i16;
+typedef signed short i16;
 #define F_I16_D "hd"
 #define F_I16_H "hX"
 
-typedef unsigned long  u32;
+typedef unsigned long u32;
 #define F_U32_D "lu"
 #define F_U32_H "lX"
 
-typedef signed   long  i32;
+typedef signed long i32;
 #define F_I32_D "ld"
 #define F_I32_H "lX"
 
@@ -92,10 +92,10 @@
  *	Platform definitions
  */
 #if defined Y_DOS
-const int Y_PATH      = 64;	// Maximum length of a path
+const int Y_PATH = 64;		// Maximum length of a path
 const int Y_FILE_NAME = 255;	// Maximum length of file name, including path
 #elif defined Y_UNIX
-const int Y_PATH      = 255;
+const int Y_PATH = 255;
 const int Y_FILE_NAME = 255;
 #endif
 typedef char y_file_name_t[Y_FILE_NAME + 1];
@@ -105,8 +105,8 @@
  *	Constants of the universe.
  */
 const double HALFPI = 1.5707963;
-const double ONEPI  = 3.1415926;
-const double TWOPI  = 6.2831852;
+const double ONEPI = 3.1415926;
+const double TWOPI = 6.2831852;
 const double ANSWER = 42;
 
 
@@ -115,7 +115,7 @@
  */
 #define y_min(a,b) ((a) < (b) ? (a) : (b))
 #define y_max(a,b) ((a) > (b) ? (a) : (b))
-const char *const Y_NULL = 0;  // NULL (const char *)
+const char *const Y_NULL = 0;	// NULL (const char *)
 
 
 /*
@@ -133,15 +133,18 @@
  *	FIXME should move as much of this as possible to the ygd file...
  *	FIXME Hexen has a different value for MIN_DEATHMATH_STARTS
  */
-const int DOOM_PLAYER_HEIGHT         = 56;
-const int DOOM_FLAT_WIDTH            = 64;
-const int DOOM_FLAT_HEIGHT           = 64;
+const int DOOM_PLAYER_HEIGHT = 56;
+const int DOOM_FLAT_WIDTH = 64;
+const int DOOM_FLAT_HEIGHT = 64;
 const size_t DOOM_MIN_DEATHMATCH_STARTS = 4;
 const size_t DOOM_MAX_DEATHMATCH_STARTS = 10;
-const size_t DOOM_COLOURS               = 256;
-typedef enum { YGPF_NORMAL, YGPF_ALPHA, YGPF_PR } ygpf_t;
-typedef enum { YGTF_NORMAL, YGTF_NAMELESS, YGTF_STRIFE11 } ygtf_t;
-typedef enum { YGTL_NORMAL, YGTL_TEXTURES, YGTL_NONE } ygtl_t;
+const size_t DOOM_COLOURS = 256;
+typedef enum
+{ YGPF_NORMAL, YGPF_ALPHA, YGPF_PR } ygpf_t;
+typedef enum
+{ YGTF_NORMAL, YGTF_NAMELESS, YGTF_STRIFE11 } ygtf_t;
+typedef enum
+{ YGTL_NORMAL, YGTL_TEXTURES, YGTL_NONE } ygtl_t;
 
 
 /*
@@ -156,24 +159,35 @@
    of all the data blocks from all the various wad files. */
 typedef struct MasterDirectory *MDirPtr;
 struct MasterDirectory
-   {
-   MDirPtr next;		// Next in list
-   const Wad_file *wadfile;	// File of origin
-   struct Directory dir;	// Directory data
-   };
+{
+    MDirPtr next;		// Next in list
+    const Wad_file *wadfile;	// File of origin
+    struct Directory dir;	// Directory data
+};
 
 /* Lump location : enough information to load a lump without
    having to do a directory lookup. */
 struct Lump_loc
-   {
-   Lump_loc () { wad = 0; }
-   Lump_loc (const Wad_file *w, i32 o, i32 l) { wad = w; ofs = o; len = l; }
-   bool operator == (const Lump_loc& other) const
-     { return wad == other.wad && ofs == other.ofs && len == other.len; }
-   const Wad_file *wad;
-   i32 ofs;
-   i32 len;
-   };
+{
+    Lump_loc()
+    {
+	wad = 0;
+    }
+    Lump_loc(const Wad_file * w, i32 o, i32 l)
+    {
+	wad = w;
+	ofs = o;
+	len = l;
+    }
+    bool operator ==(const Lump_loc & other) const
+    {
+	return wad == other.wad && ofs == other.ofs && len == other.len;
+    }
+    const Wad_file *wad;
+    i32 ofs;
+    i32 len;
+};
+
 #include "wstructs.h"
 
 
@@ -188,65 +202,65 @@
    Several different application colours may refer to the same
    physical colour. */
 typedef u8 acolour_t;
-#define ACOLOUR_NONE 0xff  // The out-of-band value
+#define ACOLOUR_NONE 0xff	// The out-of-band value
 
 /* The 16 VGA colours that DEU used to use.
    FIXME: all references to these in the code should be removed. */
-const acolour_t BLACK           = 0;
-const acolour_t BLUE            = 1;
-const acolour_t GREEN           = 2;
-const acolour_t CYAN            = 3;
-const acolour_t RED             = 4;
-const acolour_t MAGENTA         = 5;
-const acolour_t BROWN           = 6;
-const acolour_t LIGHTGREY       = 7;
-const acolour_t DARKGREY        = 8;
-const acolour_t LIGHTBLUE       = 9;
-const acolour_t LIGHTGREEN      = 10;
-const acolour_t LIGHTCYAN       = 11;
-const acolour_t LIGHTRED        = 12;
-const acolour_t LIGHTMAGENTA    = 13;
-const acolour_t YELLOW          = 14;
-const acolour_t WHITE           = 15;
+const acolour_t BLACK = 0;
+const acolour_t BLUE = 1;
+const acolour_t GREEN = 2;
+const acolour_t CYAN = 3;
+const acolour_t RED = 4;
+const acolour_t MAGENTA = 5;
+const acolour_t BROWN = 6;
+const acolour_t LIGHTGREY = 7;
+const acolour_t DARKGREY = 8;
+const acolour_t LIGHTBLUE = 9;
+const acolour_t LIGHTGREEN = 10;
+const acolour_t LIGHTCYAN = 11;
+const acolour_t LIGHTRED = 12;
+const acolour_t LIGHTMAGENTA = 13;
+const acolour_t YELLOW = 14;
+const acolour_t WHITE = 15;
 
 
 // True logical colours
-const acolour_t WINBG           = 16;
-const acolour_t WINBG_LIGHT     = 17;
-const acolour_t WINBG_DARK      = 18;
-const acolour_t WINBG_HL        = 19;
+const acolour_t WINBG = 16;
+const acolour_t WINBG_LIGHT = 17;
+const acolour_t WINBG_DARK = 18;
+const acolour_t WINBG_HL = 19;
 
-const acolour_t WINFG           = 20;
-const acolour_t WINFG_HL        = 21;
-const acolour_t WINFG_DIM       = 22;
-const acolour_t WINFG_DIM_HL    = 23;
+const acolour_t WINFG = 20;
+const acolour_t WINFG_HL = 21;
+const acolour_t WINFG_DIM = 22;
+const acolour_t WINFG_DIM_HL = 23;
 
-const acolour_t WINLABEL        = 24;
-const acolour_t WINLABEL_HL     = 25;
-const acolour_t WINLABEL_DIM    = 26;
+const acolour_t WINLABEL = 24;
+const acolour_t WINLABEL_HL = 25;
+const acolour_t WINLABEL_DIM = 26;
 const acolour_t WINLABEL_DIM_HL = 27;
 
-const acolour_t GRID1           = 28;
-const acolour_t GRID2H          = 29;
-const acolour_t GRID2V          = 30;
-const acolour_t GRID3H          = 31;
-const acolour_t GRID3V          = 32;
-const acolour_t GRID4H          = 33;
-const acolour_t GRID4V          = 34;
-const acolour_t LINEDEF_NO      = 35;
-const acolour_t SECTOR_NO       = 36;
-const acolour_t THING_NO        = 37;
-const acolour_t VERTEX_NO       = 38;
-const acolour_t CLR_ERROR       = 39;
-const acolour_t THING_REM       = 40;	// Things when not in things mode
+const acolour_t GRID1 = 28;
+const acolour_t GRID2H = 29;
+const acolour_t GRID2V = 30;
+const acolour_t GRID3H = 31;
+const acolour_t GRID3V = 32;
+const acolour_t GRID4H = 33;
+const acolour_t GRID4V = 34;
+const acolour_t LINEDEF_NO = 35;
+const acolour_t SECTOR_NO = 36;
+const acolour_t THING_NO = 37;
+const acolour_t VERTEX_NO = 38;
+const acolour_t CLR_ERROR = 39;
+const acolour_t THING_REM = 40;	// Things when not in things mode
 
-const acolour_t SECTOR_TAG      = 41;
-const acolour_t SECTOR_TAGTYPE  = 42;
-const acolour_t SECTOR_TYPE     = 43;
+const acolour_t SECTOR_TAG = 41;
+const acolour_t SECTOR_TAGTYPE = 42;
+const acolour_t SECTOR_TYPE = 43;
 
-const acolour_t WINTITLE        = 44;
+const acolour_t WINTITLE = 44;
 
-const acolour_t NCOLOURS        = 45;
+const acolour_t NCOLOURS = 45;
 
 
 /*
@@ -257,37 +271,37 @@
 // Operations on the selection :
 typedef enum
 {
-  YS_ADD    = BV_SET,	// Add to selection
-  YS_REMOVE = BV_CLEAR,	// Remove from selection
-  YS_TOGGLE = BV_TOGGLE	// If not in selection, add; else, remove
+    YS_ADD = BV_SET,		// Add to selection
+    YS_REMOVE = BV_CLEAR,	// Remove from selection
+    YS_TOGGLE = BV_TOGGLE	// If not in selection, add; else, remove
 } sel_op_t;
 
 // Confirmation options are stored internally this way :
 typedef enum
-   {
-   YC_YES      = 'y',
-   YC_NO       = 'n',
-   YC_ASK      = 'a',
-   YC_ASK_ONCE = 'o'
-   } confirm_t;
+{
+    YC_YES = 'y',
+    YC_NO = 'n',
+    YC_ASK = 'a',
+    YC_ASK_ONCE = 'o'
+} confirm_t;
 
 // Bit bashing operations
-const int YO_AND    = 'a';  // Argument = mask
-const int YO_CLEAR  = 'c';  // Argument = bit#
-const int YO_COPY   = 'd';  // Argument = source_bit# dest_bit#
-const int YO_OR     = 'o';  // Argument = mask
-const int YO_SET    = 's';  // Argument = bit#
-const int YO_TOGGLE = 't';  // Argument = bit#
-const int YO_XOR    = 'x';  // Argument = mask
+const int YO_AND = 'a';		// Argument = mask
+const int YO_CLEAR = 'c';	// Argument = bit#
+const int YO_COPY = 'd';	// Argument = source_bit# dest_bit#
+const int YO_OR = 'o';		// Argument = mask
+const int YO_SET = 's';		// Argument = bit#
+const int YO_TOGGLE = 't';	// Argument = bit#
+const int YO_XOR = 'x';		// Argument = mask
 
 
 /*
  *	Even more stuff ("the macros and constants")
  */
 
-extern const char *const log_file;        // "yadex.log"
-extern const char *const msg_unexpected;  // "unexpected error"
-extern const char *const msg_nomem;       // "Not enough memory"
+extern const char *const log_file;	// "yadex.log"
+extern const char *const msg_unexpected;	// "unexpected error"
+extern const char *const msg_nomem;	// "Not enough memory"
 
 // Convert screen/window coordinates to map coordinates
 #define MAPX(x)		(OrigX + (int) (((int) (x) - ScrCenterX) / Scale))
@@ -307,9 +321,9 @@
  *	fashion than by just returning NULL and setting
  *	a global variable.
  */
-extern char error_non_unique[1];  // Found more than one
-extern char error_none[1];        // Found none
-extern char error_invalid[1];     // Invalid parameter
+extern char error_non_unique[1];	// Found more than one
+extern char error_none[1];	// Found none
+extern char error_invalid[1];	// Invalid parameter
 
 
 /*
@@ -317,44 +331,44 @@
  */
 
 // Defined in yadex.cc
-extern const char *install_dir; 	// Where yadex is installed
-extern FILE *logfile;			// Filepointer to the error log
-extern bool  Registered;		// Registered or shareware iwad ?
-extern int screen_lines;		// Lines that our TTY can display
+extern const char *install_dir;	// Where yadex is installed
+extern FILE *logfile;		// Filepointer to the error log
+extern bool Registered;		// Registered or shareware iwad ?
+extern int screen_lines;	// Lines that our TTY can display
 extern int remind_to_build_nodes;	// Remind the user to build nodes
 
 // Defined in yadex.c and set from
 // command line and/or config file
-extern bool  autoscroll;	// Autoscrolling enabled.
-extern unsigned long autoscroll_amp;// Amplitude in percents of screen/window size.
-extern unsigned long autoscroll_edge; // Max. dist. in pixels to edge.
+extern bool autoscroll;		// Autoscrolling enabled.
+extern unsigned long autoscroll_amp;	// Amplitude in percents of screen/window size.
+extern unsigned long autoscroll_edge;	// Max. dist. in pixels to edge.
 extern const char *config_file;	// Name of the configuration file
-extern int   copy_linedef_reuse_sidedefs;
-extern int   cpu_big_endian;	// Am I running on a big-endian CPU ?
-extern bool  Debug;			// Are we debugging?
-extern int   default_ceiling_height;			// For new sectors
-extern char  default_ceiling_texture[WAD_FLAT_NAME + 1];// For new sectors
-extern int   default_floor_height;			// For new sectors
-extern char  default_floor_texture[WAD_FLAT_NAME + 1];	// For new sectors
-extern int   default_light_level;			// For new sectors
-extern char  default_lower_texture[WAD_TEX_NAME + 1];	// For new linedefs
-extern char  default_middle_texture[WAD_TEX_NAME + 1];	// For new linedefs
-extern int   default_thing;				// For new THINGS
-extern char  default_upper_texture[WAD_TEX_NAME + 1];	// For new linedefs
-extern int   double_click_timeout;// Max ms between clicks of double click.
-extern bool  Expert;		// Don't ask for confirmation for some ops.
+extern int copy_linedef_reuse_sidedefs;
+extern int cpu_big_endian;	// Am I running on a big-endian CPU ?
+extern bool Debug;		// Are we debugging?
+extern int default_ceiling_height;	// For new sectors
+extern char default_ceiling_texture[WAD_FLAT_NAME + 1];	// For new sectors
+extern int default_floor_height;	// For new sectors
+extern char default_floor_texture[WAD_FLAT_NAME + 1];	// For new sectors
+extern int default_light_level;	// For new sectors
+extern char default_lower_texture[WAD_TEX_NAME + 1];	// For new linedefs
+extern char default_middle_texture[WAD_TEX_NAME + 1];	// For new linedefs
+extern int default_thing;	// For new THINGS
+extern char default_upper_texture[WAD_TEX_NAME + 1];	// For new linedefs
+extern int double_click_timeout;	// Max ms between clicks of double click.
+extern bool Expert;		// Don't ask for confirmation for some ops.
 extern const char *Game;	// Name of game "doom", "doom2", "heretic", ...
-extern int   grid_pixels_min;   // Minimum grid step in pixels when not locked
-extern int   GridMin;	 	// Minimum grid step in map units
-extern int   GridMax;		// Maximum grid step in map units
-extern int   idle_sleep_ms;	// Time to sleep after empty XPending()
-extern int   zoom_default;	// Initial zoom factor for map
-extern int   zoom_step;		// Step between zoom factors in percent
-extern int   digit_zoom_base;	// Zoom factor of `1' key, in percent
-extern int   digit_zoom_step;	// Step between digit keys, in percent 
+extern int grid_pixels_min;	// Minimum grid step in pixels when not locked
+extern int GridMin;		// Minimum grid step in map units
+extern int GridMax;		// Maximum grid step in map units
+extern int idle_sleep_ms;	// Time to sleep after empty XPending()
+extern int zoom_default;	// Initial zoom factor for map
+extern int zoom_step;		// Step between zoom factors in percent
+extern int digit_zoom_base;	// Zoom factor of `1' key, in percent
+extern int digit_zoom_step;	// Step between digit keys, in percent 
 extern confirm_t insert_vertex_merge_vertices;
 extern confirm_t insert_vertex_split_linedef;
-extern bool  blindly_swap_sidedefs;
+extern bool blindly_swap_sidedefs;
 extern const char *Iwad1;	// Name of the Doom iwad
 extern const char *Iwad2;	// Name of the Doom II iwad
 extern const char *Iwad3;	// Name of the Heretic iwad
@@ -367,34 +381,34 @@
 extern const char *Iwad10;	// Name of the Strife 1.0 iwad
 extern const char *MainWad;	// Name of the main wad file
 #ifdef AYM_MOUSE_HACKS
-extern int   MouseMickeysH; 
-extern int   MouseMickeysV; 
+extern int MouseMickeysH;
+extern int MouseMickeysV;
 #endif
 extern char **PatchWads;	// List of pwad files
-extern bool  Quiet;		// Don't beep when an object is selected
-extern bool  Quieter;		// Don't beep, even on error
-extern unsigned long scroll_less;// %s of screenful to scroll by
-extern unsigned long scroll_more;// %s of screenful to scroll by
-extern bool  Select0;		// Autom. select obj. 0 when switching modes
-extern int   show_help;		// Print usage message and exit.
-extern int   sprite_scale;	// Relative scale used to display sprites
-extern bool  SwapButtons;	// Swap right and middle mouse buttons
-extern int   verbose;		// Verbose mode
-extern int   welcome_message;	// Print the welcome message on startup.
+extern bool Quiet;		// Don't beep when an object is selected
+extern bool Quieter;		// Don't beep, even on error
+extern unsigned long scroll_less;	// %s of screenful to scroll by
+extern unsigned long scroll_more;	// %s of screenful to scroll by
+extern bool Select0;		// Autom. select obj. 0 when switching modes
+extern int show_help;		// Print usage message and exit.
+extern int sprite_scale;	// Relative scale used to display sprites
+extern bool SwapButtons;	// Swap right and middle mouse buttons
+extern int verbose;		// Verbose mode
+extern int welcome_message;	// Print the welcome message on startup.
 extern const char *bench;	// Benchmark to run
 
 // Defined in gfx.cc
-extern int   ScrMaxX;		// Maximum display X-coord of screen/window
-extern int   ScrMaxY;		// Maximum display Y-coord of screen/window
+extern int ScrMaxX;		// Maximum display X-coord of screen/window
+extern int ScrMaxY;		// Maximum display Y-coord of screen/window
 extern float Scale;		// Scale to draw map 20 to 1
 
 // Defined in wads.cc
-extern MDirPtr   MasterDir;	// The master directory
+extern MDirPtr MasterDir;	// The master directory
 class Serial_num;
 extern Serial_num master_dir_serial;	// The revision# thereof
 
 // Defined in edit.cc
-extern bool InfoShown;          // Is the bottom line displayed?
+extern bool InfoShown;		// Is the bottom line displayed?
 
 /*
  *	Prototypes
@@ -406,122 +420,122 @@
  */
 
 // checks.cc (previously in editobj.cc)
-void CheckLevel (int, int, int pulldown); /* SWAP! */
-bool CheckStartingPos (void); /* SWAP! */
+void CheckLevel(int, int, int pulldown);	/* SWAP! */
+bool CheckStartingPos(void);	/* SWAP! */
 
 // colour1.cc
-int getcolour (const char *s, rgb_c *rgb);
+int getcolour(const char *s, rgb_c * rgb);
 
 // colour2.cc
-int rgb2irgb (int r, int g, int b);
+int rgb2irgb(int r, int g, int b);
 
 // colour3.cc
-void irgb2rgb (int c, rgb_c *rgb);
+void irgb2rgb(int c, rgb_c * rgb);
 
 // editobj.cc
-int InputObjectNumber (int, int, int, int);
-int InputObjectXRef (int, int, int, bool, int);
-bool Input2VertexNumbers (int, int, const char *, int *, int *);
-void EditObjectsInfo (int, int, int, SelPtr);
-void InsertStandardObject (int, int, int choice); /* SWAP! */
-void MiscOperations (int, SelPtr *, int choice); /* SWAP! */
+int InputObjectNumber(int, int, int, int);
+int InputObjectXRef(int, int, int, bool, int);
+bool Input2VertexNumbers(int, int, const char *, int *, int *);
+void EditObjectsInfo(int, int, int, SelPtr);
+void InsertStandardObject(int, int, int choice);	/* SWAP! */
+void MiscOperations(int, SelPtr *, int choice);	/* SWAP! */
 
 // game.cc
-void InitGameDefs (void);
-void LoadGameDefs (const char *game);
-void FreeGameDefs (void);
+void InitGameDefs(void);
+void LoadGameDefs(const char *game);
+void FreeGameDefs(void);
 
 // geom.cc
-unsigned ComputeAngle (int, int);
-unsigned ComputeDist (int, int);
+unsigned ComputeAngle(int, int);
+unsigned ComputeDist(int, int);
 
 // input.cc
 #include "input.h"
 
 // l_align.cc (previously in objects.cc)
-void AlignTexturesY (SelPtr *); /* SWAP! */
-void AlignTexturesX (SelPtr *); /* SWAP! */
+void AlignTexturesY(SelPtr *);	/* SWAP! */
+void AlignTexturesX(SelPtr *);	/* SWAP! */
 
 // l_misc.cc (previously in objects.cc)
-void FlipLineDefs (SelPtr, bool); /* SWAP! */
-void SplitLineDefs (SelPtr); /* SWAP! */
-void MakeRectangularNook (SelPtr obj, int width, int depth, int convex); /* SWAP! */
-void SetLinedefLength (SelPtr obj, int length, int move_2nd_vertex);
+void FlipLineDefs(SelPtr, bool);	/* SWAP! */
+void SplitLineDefs(SelPtr);	/* SWAP! */
+void MakeRectangularNook(SelPtr obj, int width, int depth, int convex);	/* SWAP! */
+void SetLinedefLength(SelPtr obj, int length, int move_2nd_vertex);
 
 // l_prop.cc (previously in editobj.cc)
-void LinedefProperties (int x0, int y0, SelPtr obj);
-void TransferLinedefProperties (int src_linedef, SelPtr linedefs);
+void LinedefProperties(int x0, int y0, SelPtr obj);
+void TransferLinedefProperties(int src_linedef, SelPtr linedefs);
 
 // l_unlink.cc
-void unlink_sidedef (SelPtr linedefs, int side1, int side2);
+void unlink_sidedef(SelPtr linedefs, int side1, int side2);
 
 // levels.cc
-int ReadLevelData (const char *); /* SWAP! */
-void ForgetLevelData (void); /* SWAP! */
-int SaveLevelData (const char *, const char *level_name); /* SWAP! */
-void ReadWTextureNames (void);
-void ForgetFTextureNames (void);
-int is_flat_name_in_list (const char *name);
-void ReadFTextureNames (void);
-void ForgetWTextureNames (void);
+int ReadLevelData(const char *);	/* SWAP! */
+void ForgetLevelData(void);	/* SWAP! */
+int SaveLevelData(const char *, const char *level_name);	/* SWAP! */
+void ReadWTextureNames(void);
+void ForgetFTextureNames(void);
+int is_flat_name_in_list(const char *name);
+void ReadFTextureNames(void);
+void ForgetWTextureNames(void);
 
 // names.cc
-const char *GetObjectTypeName (int);
-const char *GetEditModeName (int);
-const char *GetLineDefTypeName (int);
-const char *GetLineDefTypeLongName (int);
-const char *GetLineDefFlagsName (int);
-const char *GetLineDefFlagsLongName (int);
-const char *GetSectorTypeName (int);
-const char *GetSectorTypeLongName (int);
+const char *GetObjectTypeName(int);
+const char *GetEditModeName(int);
+const char *GetLineDefTypeName(int);
+const char *GetLineDefTypeLongName(int);
+const char *GetLineDefFlagsName(int);
+const char *GetLineDefFlagsLongName(int);
+const char *GetSectorTypeName(int);
+const char *GetSectorTypeLongName(int);
 
 // nop.cc
-void nop (...);
+void nop(...);
 
 // s_door.cc (previously in objects.cc)
-void MakeDoorFromSector (int); /* SWAP! */
+void MakeDoorFromSector(int);	/* SWAP! */
 
 // s_lift.cc (previously in objects.cc)
-void MakeLiftFromSector (int); /* SWAP! */
+void MakeLiftFromSector(int);	/* SWAP! */
 
 // s_merge.cc (previously in objects.cc)
-void MergeSectors (SelPtr *); /* SWAP! */
-void DeleteLineDefsJoinSectors (SelPtr *); /* SWAP! */
+void MergeSectors(SelPtr *);	/* SWAP! */
+void DeleteLineDefsJoinSectors(SelPtr *);	/* SWAP! */
 
 // s_misc.cc (previously in objects.cc)
-void DistributeSectorFloors (SelPtr); /* SWAP! */
-void DistributeSectorCeilings (SelPtr); /* SWAP! */
-void RaiseOrLowerSectors (SelPtr obj);
-void BrightenOrDarkenSectors (SelPtr obj);
-void SuperSectorSelector (int map_x, int map_y, int new_sec);
+void DistributeSectorFloors(SelPtr);	/* SWAP! */
+void DistributeSectorCeilings(SelPtr);	/* SWAP! */
+void RaiseOrLowerSectors(SelPtr obj);
+void BrightenOrDarkenSectors(SelPtr obj);
+void SuperSectorSelector(int map_x, int map_y, int new_sec);
 
 // s_prop.cc (previously in editobj.cc)
-void SectorProperties (int x0, int y0, SelPtr obj);
-void TransferSectorProperties (int src_sector, SelPtr sectors);
+void SectorProperties(int x0, int y0, SelPtr obj);
+void TransferSectorProperties(int src_sector, SelPtr sectors);
 
 // s_split.cc (previously in objects.cc)
-void SplitSector (int, int); /* SWAP! */
-void SplitLineDefsAndSector (int, int); /* SWAP! */
-void MultiSplitLineDefsAndSector (int, int); /* SWAP! */
+void SplitSector(int, int);	/* SWAP! */
+void SplitLineDefsAndSector(int, int);	/* SWAP! */
+void MultiSplitLineDefsAndSector(int, int);	/* SWAP! */
 
 // scrnshot.cc
-void ScreenShot (void);
+void ScreenShot(void);
 
 // selrect.cc
 // t_prop.c (previously in editobj.c)
-void ThingProperties (int x0, int y0, SelPtr obj);
-void TransferThingProperties (int src_thing, SelPtr things);
+void ThingProperties(int x0, int y0, SelPtr obj);
+void TransferThingProperties(int src_thing, SelPtr things);
 
 // v_merge.cc
-void DeleteVerticesJoinLineDefs (SelPtr ); /* SWAP! */
-void MergeVertices (SelPtr *); /* SWAP! */
-bool AutoMergeVertices (SelPtr *, int obj_type, char operation); /* SWAP! */
+void DeleteVerticesJoinLineDefs(SelPtr);	/* SWAP! */
+void MergeVertices(SelPtr *);	/* SWAP! */
+bool AutoMergeVertices(SelPtr *, int obj_type, char operation);	/* SWAP! */
 
 // v_polyg.cc
-void InsertPolygonVertices (int, int, int, int);
+void InsertPolygonVertices(int, int, int, int);
 
 // verbmsg.cc
-void verbmsg (const char *fmt, ...);
+void verbmsg(const char *fmt, ...);
 
 // version.cc
 extern const char *const yadex_version;
@@ -534,17 +548,17 @@
 extern const char *const yadex_ygd_common;
 
 // wads.cc
-MDirPtr FindMasterDir (MDirPtr, const char *);
-MDirPtr FindMasterDir (MDirPtr, const char *, const char *);
-int entryname_cmp (const char *entry1, const char *entry2);
+MDirPtr FindMasterDir(MDirPtr, const char *);
+MDirPtr FindMasterDir(MDirPtr, const char *, const char *);
+int entryname_cmp(const char *entry1, const char *entry2);
 
 // warning.cc
-void warn (const char *fmt, ...);
+void warn(const char *fmt, ...);
 
 // yadex.cc
-void Beep (void);
-void PlaySound (int, int);
-void LogMessage (const char *, ...);
+void Beep(void);
+void PlaySound(int, int);
+void LogMessage(const char *, ...);
 
 
-#endif  /* DO NOT ADD ANYTHING AFTER THIS LINE */
+#endif /* DO NOT ADD ANYTHING AFTER THIS LINE */
--- a/src/yerror.h	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/yerror.h	Sat Sep 24 14:16:04 2011 +0300
@@ -4,9 +4,6 @@
  */
 
 
-void fatal_error (const char *fmt, ...);
-void err (const char *fmt, ...);
-void nf_bug (const char *fmt, ...);
-
-
-
+void fatal_error(const char *fmt, ...);
+void err(const char *fmt, ...);
+void nf_bug(const char *fmt, ...);
--- a/src/ymemory.h	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/ymemory.h	Sat Sep 24 14:16:04 2011 +0300
@@ -5,6 +5,6 @@
  */
 
 
-void *GetMemory (unsigned long size);
-void *ResizeMemory (void *, unsigned long size);
-void FreeMemory (void *);
+void *GetMemory(unsigned long size);
+void *ResizeMemory(void *, unsigned long size);
+void FreeMemory(void *);
--- a/src/ytime.cc	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/ytime.cc	Sat Sep 24 14:16:04 2011 +0300
@@ -38,22 +38,19 @@
 /*
  *	Return the current time in ms
  */
-unsigned long y_milliseconds ()
+unsigned long y_milliseconds()
 {
 #ifdef Y_GETTIMEOFDAY
-  struct timeval tv;
-  struct timezone tz;
-  if (gettimeofday (&tv, &tz))
-  {
-    nf_bug ("gettimeofday() error (%s)", strerror (errno));
-    return 0;
-  }
-  return tv.tv_sec * 1000 + tv.tv_usec / 1000;
-#else  /* Sucks ! */
-  static const double ms_per_clock = 1000.0 / CLOCKS_PER_SEC;
-  return (unsigned long) (clock () * ms_per_clock);
+    struct timeval tv;
+    struct timezone tz;
+    if (gettimeofday(&tv, &tz))
+    {
+	nf_bug("gettimeofday() error (%s)", strerror(errno));
+	return 0;
+    }
+    return tv.tv_sec * 1000 + tv.tv_usec / 1000;
+#else /* Sucks ! */
+    static const double ms_per_clock = 1000.0 / CLOCKS_PER_SEC;
+    return (unsigned long) (clock() * ms_per_clock);
 #endif
 }
-
-
-
--- a/src/ytime.h	Sat Sep 24 13:12:09 2011 +0300
+++ b/src/ytime.h	Sat Sep 24 14:16:04 2011 +0300
@@ -4,11 +4,11 @@
  */
 
 
-#ifndef YH_YTIME  /* DO NOT INSERT ANYTHING BEFORE THIS LINE */
+#ifndef YH_YTIME		/* DO NOT INSERT ANYTHING BEFORE THIS LINE */
 #define YH_YTIME
 
 
-unsigned long y_milliseconds ();
+unsigned long y_milliseconds();
 
 
-#endif  /* DO NOT ADD ANYTHING AFTER THIS LINE */
+#endif /* DO NOT ADD ANYTHING AFTER THIS LINE */